Forum Moderators: open
<form name=example>
<select name=test onChange='Choice();'>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</form>
How would I access the value between the 2 option tags for the purposes of copying it into a text field?
I know how to do it if I wanted the actual value (i.e. 1, 2 or 3), but how would I access the actual text (one, two, three).
I know for the former I would use something like "myTextField.test.value = example.test.value;" but how would I do the latter.
<select name="testing" onChange='Choice();'>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</form>
var s=document.example.testing;
var txt=s.options[s.selectedIndex].text
or
var s=document.getElementsByName('testing')[0];
var txt=s.options[s.selectedIndex].firstChild.nodeValue