uxair
01-10-2007, 06:05 AM
I'm trying to find the selectedindex of the option which is selected by the user, but the following code show undefined whenever change occurs
<html>
<body>
<form>
<select id="ddlCar" name="cars" onchange="alert( String( document.getElementById( 'ddlCar' ).selectedindex ) );">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat" selected="selected">Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
</body>
</html>
<html>
<body>
<form>
<select id="ddlCar" name="cars" onchange="alert( String( document.getElementById( 'ddlCar' ).selectedindex ) );">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat" selected="selected">Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
</body>
</html>