Luey
asked on
onchange from list menu
Hello i want to run my javascript when only the selection in my list menu of "New Homes for Sale" and if any other is selected i do not want to run my javascript.
thanks
thanks
<html>
<head>
<script type="text/javascript">
function writeField(){
document.getElementById('field2').value = document.getElementById('field1').value ;
return true;
}
</script>
</head>
<body>
<p>
<input name="field1" id="field1" type="hidden" value="1">
</p>
<p>
<label>
<input name="field2" type="text" id="field2" value="0">
</label>
</p>
<select name="property_type" class="text_field_small" id="property_type" onChange="return writeField();">
<option value="Choose Type">Choose Type</option>
<option value="REAL" >New Home for Sale</option>
<option value="REAL">Used Home for Sale</option>
<option value="HOME">Home for Rent</option>
<option value="LAND">Land for Sale</option>
<option value="COMS" >New Commercial for Sale</option>
<option value="COMS">Used Commercial for Sale</option>
<option value="COMR">Commercial for Rent</option>
</select>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a bunch
You're welcome! Thanks for the points!
ASKER
One more question. what if i wanted to do an "and" in the selected index. Say i want to do number 1 and number 5 in the selected index.
use the logical OR operator || : if(this.selectedIndex == 1 || this.selectedIndex == 5) return writeField();
ASKER
Thanks for all your help!!
np
Without the "s" and by check the selected text :
Open in new window