You are here: irt.org | FAQ | JavaScript | Form | 3.1 | Q887 [ previous next ]
Try the following which places the selected options value and text value in two global JavaScript variables:
<script language="JavaScript"><!--
var selectedOptionValue = null;
var selectedOptionText = null;
function changed(what) {
selectedOptionValue = what.options[what.selectedIndex].value;
selectedOptionText = what.options[what.selectedIndex].text;
}
//--></script>
<form onSubmit="return false">
<select onChange="changed(this)">
<option value="first value">first text
<option value="second value">second text
</select>
</form>