Populating a text field from a drop-down menu
Pretty simple — I'm sure you guys have seen this. A user selects an option from a drop down menu. The change function then takes that data to populate a text field with it.
I'm just having trouble making it work.
Am I close?
-
<form method="post" action="#">
<select name="menu" id="menu" />
<option value="one">one</option>
<option value="two">two</option>
<option value="two">three</option>
</select>
<input type="results" name="results" id="results" />
</form>
<script type="text/javascript">
$(document).ready(function() {
$("#menu").change(function(){
var thisValue = $(this).val();
switch (thisValue) {
case "1":
//code to display string in #results
break;
case "2":
//code to display string in #results
break;
case "3":
//code to display string in #results
break;
}
});
</script>