In message <Xn********************@194.109.133.242> - "Evertjan."
<ex**************@interxnl.net> writes:
:>
:>rob c wrote on 18 apr 2006 in comp.lang.javascript
:
:>
:>> I'm not sure if this is the right place to ask for help on forms and
:>> radio buttons...
:>>
:>> In the following form, I'd like to set the value of 'item_name' based
:>> on which radio button was selected.
:>> If amount=14, then I want to set item_name='5x7 print'.
:>> If amount=20, then I want to set item_name='5x7 print (drymounted)'.
:>>
:>> <form target='paypal' action='https://www.paypal.com/cgi-bin/webscr'
:>> method='post'>
:>> <input type='hidden' name='add' value='1'>
:>> <input type='hidden' name='cmd' value='_cart'>
:>> <input type='hidden' name='quantity' value='1'>
:>> <input type='hidden' name='on0' value='Image'>
:>> <input type='hidden' name='os0' value=362_0515'>
:>> <input type='hidden' name='item_name' value='5x7'>
:>>
:>> <input checked type='radio' name='amount' value='14.00'>
:>> <input type='radio' name='amount' value='20.00'>
:>>
:>>
:>
:><form target='paypal'
:>action='https://www.paypal.com/cgi-bin/webscr'
:>method='post'
:>onsubmit="
:>this.item_name.value=
:>(this.amount[0].checked)
:>?'5x7 print'
:>:'5x7 print (drymounted)'">
:>
:><input type='hidden' name='item_name' value='5x7'>
:><input checked type='radio' name='amount' value='14.00'> 14.00<br>
:><input type='radio' name='amount' value='20.00'> 20.00<br>
:>...........
:>
:>
:>--
:>Evertjan.
:>The Netherlands.
:>(Please change the x'es to dots in my emailaddress)
Thanks for the help!!!
I used the <form ... onsubmit...> method with a slight change to my original
idea.
I decided to leave the item_name variable unchanged after discovering that
PayPal has a second set of 'option values' (on1 and os1). So I added:
<input type='hidden' name='on1' value='Dry Mounted'>
<input type='hidden' name='os1' value='not set yet'>
And the <form> line looks like this:
<form target='paypal'
action='https://www.paypal.com/cgi-bin/webscr'
method='post'
onsubmit='this.os1.value=(this.amount[0].checked)?"No":"Yes"'>
The results from PayPal show as "Dry Mounted: Yes" or "No". If "not set yet"
appears then there is a problem, maybe I should change that to something like
"there's been an error - please let me know about it".
Thanks again!
Rob
www.rcp.ca