Results 1 to 6 of 6

Thread: Help to get button to direct properly

  1. #1
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Help to get button to direct properly

    Hi,

    I have some script which creates a button, however onclick it does not do what I would like it to do and that is go to the payfast page.

    PHP Code:
    <tr class="alt2">
    <
    td>GARETH TINDALL</td>
    <
    td>BOLAND</td>
    <
    td>STRAND</td>
    <
    td>?</td>
    <
    td>
    <
    button id="AdvancedButton2" type="button" onClick="window.location=''" name="AdvancedButton1" style="width:66px;height:20px;background-color:#98ABCE;"><div><font style="font-size:11px" color="#000000" face="Arial">PAY NOW</font></div></button>
    <
    form action="https://www.payfast.co.za/eng/process" method="post">
    <
    input type="hidden" name="cmd" value="_paynow">
    <
    input type="hidden" name="receiver" value="r*****@m***b.coza">
    <
    input type="hidden" name="item_name" value="GNJGF Tournament Payment">
    <
    input type="hidden" name="item_description" value="payment">
    <
    input type="hidden" name="amount" value="151.00">
    <
    input type="hidden" name="return_url" value="http://www.gnjgf.co.za/entryform.php">
    <
    input type="hidden" name="cancel_url" value="http://www.gnjgf.co.za/d.php">
    </
    td>
    </
    form>
    </
    tr
    Any help here would be most helpful?

    Kind Regards
    Rob
    Last edited by Rob (SA); 09-19-2010 at 09:55 AM.

  2. #2
    Join Date
    Sep 2010
    Location
    Hi Stalker.
    Posts
    148
    Thanks
    16
    Thanked 3 Times in 3 Posts

    Default

    Your
    onClick="window.location=''
    won't go to a page because, there is no location to go to.
    Here's an example:
    HTML Code:
    onClick="window.location='payfast.php'

  3. #3
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi Nicolas,

    Thanks for the reply.

    If I put something in there - the lines below <form action . . .
    respond with and error.

    If I leave the line <button id=. . . . .out then it direct proper;y but the button does not then have the look and feel I require

    Any comments?

    Regards
    Rob

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's invalid HTML. The button element may only contain inline content and text, perhaps only text. It's a sort of rogue element anyway. Better to use the more predictable input tag. And the form opens inside a td, and closes in an area where no form is allowed to close. You don't want your user's ability to pay to depend upon javascript either (the onclick event is javascript only). I'm not sure what you mean about the button looking different without the id, unless you have something in a stylesheet for that id, in which case we need to see that. On its own, it looks different in different browsers though. If you do it like so:

    Code:
    <tr class="alt2"> 
    <td>GARETH TINDALL</td> 
    <td>BOLAND</td> 
    <td>STRAND</td> 
    <td>?</td> 
    <td><form action="https://www.payfast.co.za/eng/process" method="post"> 
    <input type="hidden" name="cmd" value="_paynow"> 
    <input type="hidden" name="receiver" value="robhar@mweb.co.za"> 
    <input type="hidden" name="item_name" value="GNJGF Tournament Payment"> 
    <input type="hidden" name="item_description" value="payment"> 
    <input type="hidden" name="amount" value="151.00"> 
    <input type="hidden" name="return_url" value="http://www.gnjgf.co.za/entryform.php"> 
    <input type="hidden" name="cancel_url" value="http://www.gnjgf.co.za/d.php"> 
    <input id="AdvancedButton2" type="submit" name="AdvancedButton1" style="width:66px;height:20px;background-color:#98ABCE;font-size:11px; font-family: arial, sans-serif;" value="PAY NOW"> 
    </form>
    </td>
    </tr>
    At least it will be valid HTML (valid for some DTD's). More importantly it will (barring something contradictory in the stylesheet) look the same in most browsers, and it will work.

    You don't need:

    id="AdvancedButton2"

    or:

    name="AdvancedButton1"

    for functionality. But having them there doesn't prevent the input from working.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    Thanks for the help.

    DTD's

    I have got the button working - appreciated.

    Regards
    Rob

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You're welcome. And in case that was also a question about DTD's, DTD stands for:

    DOCTYPE Declaration

    Every valid DOCTYPE has one. In a URL DOCTYPE, the link to the DTD is in the DOCTYPE tag. In a DTD what's valid for that DOCTYPE is defined. You can look through a DTD at the w3c.org site to see this information.

    When you go to the w3c.org validator, or use any other validator for your page, what's supposed to happen (and usually does) is that the DOCTYPE used for the page determines the DTD against which your code is checked.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •