drop down menu and text box

liunx

Guest
hi,<br />
<br />
i'm writing an asp page where the user can have the option of either selecting an item from a text box or typing a word in a text box. then the user hits the submit button. how do i ensure that the user only has chosen either something from the drop menu or type a word in but not both.<br />
<br />
the code i have now is basically:<br />
<br />
<form .....><br />
<br />
<select name="name1"><br />
<option value="1">1<br />
<option value="2">2<br />
<option value="3">3<br />
</select><br />
<br />
<input type="text" name="name1"> <br />
<br />
<input type="submit" value="submit"><br />
<br />
</form><br />
<br />
<br />
i tried to give the two items the same name but that has problems because when the user selects something in the menu but then decides to type something in the textbox the item in the menu is still highlighted. and since i'm naming both items the same thing, if a user types in a "2" in the textbox, when i used Form.Request("name1") on the next page, i wouldn't be able to tell whether the user type that in or chose if from the menu and being able to do so is important to me. any idea?<br />
<br />
thanks,<br />
anna<!--content-->try this example:<br />
<br />
it sets the select area to the 'typed' in value and vice versa.<!--content-->You can do a number of things, but try this:<br />
<br />
<br />
<br />
<script language="javscript"><br />
<!--<br />
function check(form){<br />
if (form.name1.selectedIndex) { <br />
// a selection have been made<br />
form.name2.name = "dummy";<br />
return true;<br />
} else if(form.name2.value != ""){<br />
form.name1.name = "dummy";<br />
form.name2.name = "name1";<br />
return true;<br />
} else {<br />
alert("please select a value or write a value ! ");<br />
return false;<br />
}<br />
}<br />
//--><br />
</script><br />
<br />
<form onsubmit="return check(this)"><br />
<br />
<select name="name1"><br />
<option value="1">1<br />
<option value="2">2<br />
<option value="3">3<br />
</select><br />
<br />
<input type="text" name="name2"><br />
<br />
<input type="submit" value="submit"><br />
<br />
</form><!--content-->
 
Back
Top