I want to make an open "other" field in an HTTP radio form like in the following picture. is it possible? i had in mind something like this:
class="text"><input type="radio" name="sex" id="sex" ="male" checked />male
<input type="radio" name="sex" id="sex" value="female" /> female
<input type="text" name="sex" id="sex" value=(Entered-Value)/>enter other:
2
Answers
A simple demo snippet. It add a
change
event to the radio buttons and checks the value and based on that shows or hides the textbox.It really depends if you want to say hide/show the text box when they select other.
But, then again, they might change their mind, or not even enter anything into that text box – so you start to expand the complexity of the UI.
Sometimes its just better to drop in a radiobuttion list, edit the choices, and then drop in a div next to the rb list, float it, and you are done.
Say, like this:
And you get this:
And you code behind say can be this for the button
So, keep it simple is often the easy approach here. If 20 things on your page are OH SO having to be customized with JavaScript and all kinds of specials markup, then your project gets in trouble real fast. 10-15 things on a page, each a few minutes of time now becomes say 10-20 minutes of time, and that translates into 100-200 minutes of development time. Then the project and efforts takes way too long to finish.
And if you can try to stick to standard controls, then as above shows, the resulting code behind becomes (and stays) rather simple.