SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
May 25, 2004, 13:37 #1
- Join Date
- Sep 2001
- Location
- Amsterdam
- Posts
- 249
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
None of the above, add extra textfield
I have a dropdown, let's say like:
<select name="city">
<option value="1">amsterdam</option>
<option value="2">london</option>
<option value="3">paris</option>
<option value="4">berlin</option>
<option value="none">none of the above</option>
</select>
How can I achieve that if "none of the above" is selected a new textfield with the same name shows up where a new city can be filled in ?
-
May 25, 2004, 20:01 #2
- Join Date
- May 2003
- Posts
- 1,843
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:<html> <head> <style type="text/css"> #other { visibility: hidden; } </style> <script type="text/javascript"> function select_onchange(oSelect, oText) { var selval = oSelect.options[oSelect.selectedIndex].value; var bWhich = (selval == 'other') oText.style.visibility = (bWhich) ? 'visible' : 'hidden'; oText.disabled = !bWhich; if (bWhich) oText.focus(); } </script> </head> <body> <form> <select name="city" onchange="return select_onchange(this,other)"> <option value="">- choose city -</option> <option value="1">amsterdam</option> <option value="2">london</option> <option value="3">paris</option> <option value="4">berlin</option> <option value="other">other</option> </select> <input id="other" type="text" name="other" value="" disabled="disabled" /> </form> </body> </html>
::: certified wild guess :::
-
May 25, 2004, 22:04 #3
- Join Date
- Sep 2001
- Location
- Amsterdam
- Posts
- 249
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanx, it works like a charm.
Do you know for which browserversions it is compatible
Bookmarks