Log in

View Full Version : Help to get button to direct properly



Rob (SA)
09-18-2010, 06:04 PM
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.


<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

[Nicolas]
09-19-2010, 02:10 AM
Your
onClick="window.location=''
won't go to a page because, there is no location to go to.
Here's an example:

onClick="window.location='payfast.php'

:)

Rob (SA)
09-19-2010, 05:17 AM
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

jscheuer1
09-19-2010, 06:11 AM
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:


<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.

Rob (SA)
09-19-2010, 06:50 AM
Hi John,

Thanks for the help.

DTD's

I have got the button working - appreciated.

Regards
Rob

jscheuer1
09-19-2010, 02:38 PM
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.