...

View Full Version : Other option in webform dropdown



KatieK
12-28-2010, 05:21 PM
I have some code for a dropdown where when the 'Other' option is selected a textbox appears and the user can put in their info.

What I'm wondering is, how can i set it up so if the Other option isn't selected the dropdown info is sent to my database Name field, and if the Other option is selected it sends the info that's typed in to the Name field in my database and does nothing with the actual 'Other' label in the dropdown?

here's the code i have so far



<script language="JavaScript" type="text/javascript">
<!--
function getOther(sel,fld){
fld.style.display = (sel.selectedIndex==sel.options.length-1)?"inline":"none";
}
//-->
</script>
<select name="Name" id="Name" onchange="getOther(this,this.form.oth);">
<option>Name 1
<option>Name 2
<option>Name 3
<option>Name 4
<option>Name 5
<option>Other
</select>
<br><input type="text" name="Other" style="display: none;">

Logic Ali
12-28-2010, 05:32 PM
What I'm wondering is, how can i set it up so if the Other option isn't selected the dropdown info is sent to my database Name field, and if the Other option is selected it sends the info that's typed in to the Name field in my database and does nothing with the actual 'Other' label in the dropdown?Surely that's a matter for the receiving script on the server.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum