View Full Version : Question about radio inputs

09 Aug 2010, 10:40 PM
i have a form right now asking the cost to an event, to make it easier for user to enter, i made it into two radio input options. The first option being "free", and the second option being an input box for user to enter a price.

so i want the functionality such that

when I click the input box, the radio button will be automatically selected
the second radio option will take on the value of the number i entered

So far I have:
<input type="radio" name="cost" value="0" />Free!<br />
<input type="radio" id="cost1" name="cost"" /><input type="text" name="name" size="20" onclick="document.getElementById('cost1').checked=true" />

I don't feel like the value from the input box will be passed to the form, what's the correct/conventional way of doing this?


11 Aug 2010, 09:01 AM
You can just have the text input the same name as the radio and have the radio without value; the element's value will come from the text input...