467,145 Members | 996 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,145 developers. It's quick & easy.

forms, radio buttons and setting values

Hi

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

<input type='image' src='../graphics/cart-add.gif' border='0' name='submit'>
</form>

The live form is here:
http://www.rcp.ca/webgallery/skiing/...s/362_0515.htm

Thanks
Rob C

Apr 18 '06 #1
  • viewed: 1679
Share:
3 Replies
rob c said the following on 4/18/2006 11:04 AM:
Hi

I'm not sure if this is the right place to ask for help on forms and radio
buttons...


<URL: http://www.jibbering.com/faq/faq_not...ess.html#faBut >

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 18 '06 #2
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)
Apr 18 '06 #3
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

Apr 19 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Hamster | last post: by
3 posts views Thread by Flip | last post: by
6 posts views Thread by Kissingfish | last post: by
3 posts views Thread by teddysnips@hotmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.