Click to See Complete Forum and Search --> : accessing options in pulldown menu


terminator800tl
03-05-2003, 07:29 PM
function changeRamps()
{
var hwys=document.getElementById('hwys');
document.write("selected high way "+hwys.selectedIndex);
document.write("selected high way is"+hwys.options hwys.selectedIndex].value); // I am not getting anything
}

<select id="hwys" onchange="changeRamps()">
<option>5</option>
<option>52</option>
</select>

The first document.write prints out correctly.
The second document.write isn't workin. I am just trying to print out which highway is selected, but I can't access the option element.

khalidali63
03-05-2003, 07:32 PM
Typically the second one should not work.because once the first one writes, everything else beyond that point is out of scope.

Khalid