|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/25/2005 Posts: 9 Location: ,
|
Hi All,
I'm new to all this scripting so go easy on me.
Im creating a website that will use the PayPal Buy Now button which takes the user to the PayPal website to payment processing. (I'm only seeling a single item).
The button works great but I want to force the user to agree to the terms and conditions (T&C's) of the purchase before being allowed to make the payment. I have this simple script that works for this type of function:
<HTML>
<HEAD>
</HEAD>
<BODY>
<P>
<SCRIPT>
function Do_it ( ok )
{
if (ok ==false)
{
alert("You must agree to the Terms and Conditions before you can enter");
}
}
</SCRIPT>
<INPUT TYPE="CHECKBOX" NAME="CheckBox" VALUE="CheckBox"></P>
<INPUT TYPE="button" NAME="Submit" VALUE="Submit" onClick="Do_it(CheckBox.checked)">
</BODY>
</HTML>
But I don't know how to incorporate it into the Buy Now button. The Buy Now button script is:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="EMAIL ADDRESS GOES HERE">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="ITEM NAME GOES HERE">
<input type="hidden" name="item_number" value="WMH001">
<input type="hidden" name="amount" value="50.00">
<input type="hidden" name="page_style" value="PayPal">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="lc" value="GB">
<table><tr><td><input type="hidden" name="on0" value="Which charity do I support?">Which charity do I support?</td><td><select name="os0"><option value="Age Concern">Age Concern<option value="NSPCC">NSPCC<option value="Lupus">Lupus<option value="Cancer Research UK">Cancer Research UK</select>
</td></tr></table><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Any help will be greatly appreciated
Regrds
Dan
|
|
|
|
|
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 9/24/2004 Posts: 106 Location: ,
|
This should work:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <SCRIPT> function Do_it ( ok ) {
if (ok == false) { alert("You must agree to the Terms and Conditions before you can enter"); } else { document.form.submit(); }
}
</SCRIPT> </head> <body> <form name="form" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="EMAIL ADDRESS GOES HERE"> <input type="hidden" name="undefined_quantity" value="1"> <input type="hidden" name="item_name" value="ITEM NAME GOES HERE"> <input type="hidden" name="item_number" value="WMH001"> <input type="hidden" name="amount" value="50.00"> <input type="hidden" name="page_style" value="PayPal"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="lc" value="GB"> <table><tr><td><input type="hidden" name="on0" value="Which charity do I support?">Which charity do I support?</td><td><select name="os0"><option value="Age Concern">Age Concern<option value="NSPCC">NSPCC<option value="Lupus">Lupus<option value="Cancer Research UK">Cancer Research UK</select> </td></tr></table> I have read the terms & conditions. <INPUT TYPE="CHECKBOX" NAME="CheckBox" VALUE="CheckBox"><br> <a href="Javascript:Do_it(document.form.CheckBox.checked);"> <img src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" alt="Make payments with PayPal - it's fast, free and secure!"></a></form> </body> </html>
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/25/2005 Posts: 9 Location: ,
|
Thank-you so much mj3. It been racking my brain all day.
I might have to do my work now :)
Cheers Dan
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/25/2005 Posts: 9 Location: ,
|
Hi All,
I've modified the script to change the drop down list to 3 radio buttons and I now need this to be complusiry like the T&C's box. Any ideas?
Here is my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <SCRIPT> function Do_it ( ok ) {
if (ok == false) { alert("You must agree to the Terms and Conditions before you can enter"); } else { document.form.submit(); }
}
</SCRIPT> </head> <body> <form name="form" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="E-MAIL ADRESS"> <input type="hidden" name="undefined_quantity" value="1"> <input type="hidden" name="item_name" value="ITEM NAME"> <input type="hidden" name="item_number" value="WMH001"> <input type="hidden" name="amount" value="50.00"> <input type="hidden" name="page_style" value="PayPal"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="lc" value="GB">
<table>
<tr>
<td>
<input type="hidden" name="on0" value="Which charity do I support?">Which charity do I support?
</td>
<td>
<input type="radio" name="os0" value="NSPCC"> NSPCC <input type="radio" name="os0" value="Lupus"> Lupus <input type="radio" name="os0" value="Cancer Research"> Cancer Research
</select>
</td>
</tr>
</table>
<p>
<INPUT TYPE="CheckBox" NAME="CheckBox" VALUE="CheckBox"> I have read the terms & conditions. <br>
<a href="Javascript:Do_it(document.form.CheckBox.checked);">
<img src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" alt="Make payments with PayPal - it's fast, free and secure!"></a></form> </body> </html>
Any help would be greatly appreciated.
Thanks Dan
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 9/24/2004 Posts: 106 Location: ,
|
Try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <SCRIPT> function Do_it ( checkbox, radiobutton ) { if (checkbox == false) { alert("You must agree to the Terms and Conditions before you can enter"); } else if(radiobutton == "false") { alert("You must select a charity before you can enter"); } else { document.form.submit(); }
}
</SCRIPT> </head> <body> <form name="form" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="E-MAIL ADRESS"> <input type="hidden" name="undefined_quantity" value="1"> <input type="hidden" name="item_name" value="ITEM NAME"> <input type="hidden" name="item_number" value="WMH001"> <input type="hidden" name="amount" value="50.00"> <input type="hidden" name="page_style" value="PayPal"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="lc" value="GB">
<table>
<tr>
<td>
<input type="hidden" name="on0" value="Which charity do I support?">Which charity do I support?
</td>
<td>
<input type="radio" name="os0" value="NSPCC" onClick="javascript:document.form.radiochecked='true';"> NSPCC <input type="radio" name="os0" value="Lupus" onClick="javascript:document.form.radiochecked='true';"> Lupus <input type="radio" name="os0" value="Cancer Research" onClick="javascript:document.form.radiochecked='true';"> Cancer Research <input type="hidden" name="radioChecked" value="false">
</select>
</td>
</tr>
</table>
<p>
<INPUT TYPE="CheckBox" NAME="CheckBox" VALUE="CheckBox"> I have read the terms & conditions. <br>
<a href="Javascript:Do_it(document.form.CheckBox.checked, document.form.radioChecked.value);">
<img src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" alt="Make payments with PayPal - it's fast, free and secure!"></a></form> </body> </html>
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/25/2005 Posts: 9 Location: ,
|
Hi mj3,
Thanks for the quick reply. I've tried with code in IE and Mozilla and it doesn't seem to allow the user to execute the Pay Now button.
The test for else if(radiobutton == "false") always seems to be true. (Well i think it does).
When the user selects a radio button and checks the terms box this the dialog box appears: You must select a charity before you can enter.
I've tried modifing it but without any luck.
Are you able to help?
Cheers Dan
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 11/24/2002 Posts: 2,004 Location: ,
|
The problem is that you cannot just test "radiobutton". That may be an IE extension, but it is not normal code. You must identify the "path" to the button. I think mj3 meant this as a metaphorical name...
You have two problems. The first is that "radiobutton" is not defined properly, and the 2nd is that the script does not support the "general" case. It is really simple to do, and I'm gonna give it to you without flair.... (start with your first example)...
1. drop the JavaScript (take it out). 2. take your checkbox and submit lines and put them into the botton code (anywhere), but without the event handler code.... 3. change your FORM statement from this...
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
to this...
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="return this.CheckBox.checked;">
And it shall work just fine...
Ron.
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 9/24/2004 Posts: 106 Location: ,
|
just seen, with my code the lines: onClick="javascript:document.form.radiochecked='true';"
should be
onClick="javascript:document.form.radioChecked.value='true';"
this line occurs for all 3 radio buttons, then it does work
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/25/2005 Posts: 9 Location: ,
|
Hi Ron,
I'd done what you suggested and the script on checks that the checkbox is checked and not the radio buttons. This is the same as the first replt from mj3. I need both the check box and one radio button selected.
Cheers Dan
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/25/2005 Posts: 9 Location: ,
|
Hi mj3,
Thanks so much for that, it's really appreciated.
Thanks for you advice Ron.
Cheers Dan
Incase anyone wants to knwo the findal code is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <SCRIPT> function Do_it ( checkbox, radiobutton ) { if (checkbox == false) { alert("You must agree to the Terms and Conditions before you can enter"); } else if(radiobutton == "false") { alert("You must select a charity before you can enter"); } else { document.form.submit(); }
}
</SCRIPT> </head> <body> <form name="form" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="E-MAIL ADRESS"> <input type="hidden" name="undefined_quantity" value="1"> <input type="hidden" name="item_name" value="ITEM NAME"> <input type="hidden" name="item_number" value="WMH001"> <input type="hidden" name="amount" value="50.00"> <input type="hidden" name="page_style" value="PayPal"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="lc" value="GB">
<table>
<tr>
<td>
<input type="hidden" name="on0" value="Which charity do I support?">Which charity do I support?
</td>
<td>
<input type="radio" name="os0" value="NSPCC" onClick="javascript:document.form.radioChecked.value='true';"> NSPCC <input type="radio" name="os0" value="Lupus" onClick="javascript:document.form.radioChecked.value='true';"> Lupus <input type="radio" name="os0" value="Cancer Research" onClick="javascript:document.form.radioChecked.value='true';"> Cancer Research <input type="hidden" name="radioChecked" value="false">
</select>
</td>
</tr>
</table>
<p>
<INPUT TYPE="CheckBox" NAME="CheckBox" VALUE="CheckBox"> I have read the terms & conditions. <br>
<a href="Javascript:Do_it(document.form.CheckBox.checked, document.form.radioChecked.value);">
<img src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" alt="Make payments with PayPal - it's fast, free and secure!"></a></form> </body> </html>
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 1/12/2012 Posts: 1 Location: Arkansas
|
bloy.d I have a similar problem and I am a complete noob. I rent lawn announcement displays, like the big stork you may have seen in a yard announcing a new birth. The code for my button is as follows: <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="UV2NANNXUG77U"> <table> <tr><td><input type="hidden" name="on0" value="Display Dates">Display Dates</td></tr><tr><td><select name="os0"> <option value="One Day">One Day $45.00 USD</option> <option value="Two Day">Two Day $80.00 USD</option> <option value="Three Day">Three Day $105.00 USD</option> <option value="Four Day">Four Day $130.00 USD</option> <option value="Five Day">Five Day $155.00 USD</option> <option value="Six Day">Six Day $180.00 USD</option> <option value="Seven Day">Seven Day $205.00 USD</option> </select> </td></tr> <tr><td><input type="hidden" name="on1" value="Enter Phone #">Enter Phone #</td></tr><tr><td><input type="text" name="os1" maxlength="200"></td></tr> </table> <input type="hidden" name="currency_code" value="USD"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> I want to force the customer to accept Rental and Refund Agreement before going to PayPal Payment Page. I have seen the code samples here and I have no idea where to paste them. Thanks in advance for your kind response. My web page is http://geocals.net/Pages/Storks.html
|
|
|
|
Guest
|
YAFVision Theme by Jaben Cargman (Tiny Gecko)Powered by YAF |
YAF © 2003-2009, Yet Another Forum.NETThis page was generated in 0.499 seconds.