forms, radio buttons and setting values

R

rob c

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:
www.rcp.ca/webgallery/skiing/060324/pages/362_0515.htm

Thanks
Rob C
 
E

Evertjan.

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

Lee

rob c said:
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:
www.rcp.ca/webgallery/skiing/060324/pages/362_0515.htm


<input checked
type='radio'
onclick="if(checked)this.form.item_name.value='5x7'"
name='amount'
value='14.00'>

<input type='radio'
onclick="if(checked)this.form.item_name.value='5x7 print (drymounted)'"
name='amount'
value='20.00'>

You won't be able to prevent clever people from selecting the $14 item, but then
setting the value of item_name to '5x7 print (drymounted)' before submitting the
form.

Visitors who don't have Javascript enabled might end up being charged for
mounting, but not having the item_name updated to reflect their choice.


--
 
R

rob c

In message <[email protected]> - "Evertjan."
:>
:>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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top