<html>
<body>
<select id="slct" onchange="slct();">
<option value="1">Volvo</option>
<option value="2">Saab</option>
<option value="3">Mercedes</option>
<option value="4">Audi</option>
</select>
<script>
function slct(){
var selObj = document.getElementById('slct');
var selIndex = selObj.selectedIndex;
alert(selIndex);
alert(selObj.options[selIndex].value);
alert(selObj.options[selIndex].text);
}
</script>
</body>
</html>
<body>
<select id="slct" onchange="slct();">
<option value="1">Volvo</option>
<option value="2">Saab</option>
<option value="3">Mercedes</option>
<option value="4">Audi</option>
</select>
<script>
function slct(){
var selObj = document.getElementById('slct');
var selIndex = selObj.selectedIndex;
alert(selIndex);
alert(selObj.options[selIndex].value);
alert(selObj.options[selIndex].text);
}
</script>
</body>
</html>
No comments:
Post a Comment