作者在 2009-03-13 15:37:41 发布以下内容
如何获取select标签值
<html>
<script language="javascript">
function ff(){
alert(form1.cars.options[form1.cars.selectedIndex].value);
}
</script>
<body>
<script language="javascript">
function ff(){
alert(form1.cars.options[form1.cars.selectedIndex].value);
}
</script>
<body>
<form name="form1">
<select name="cars">
<option value="1">Volvo</option>
<option value="2">Saab</option>
<option value="3">Fiat</option>
<option value="4">Audi</option>
</select>
<input type="button" value="abc" onclick="ff();">
</form>
<select name="cars">
<option value="1">Volvo</option>
<option value="2">Saab</option>
<option value="3">Fiat</option>
<option value="4">Audi</option>
</select>
<input type="button" value="abc" onclick="ff();">
</form>
</body>
</html>
</html>
这是获取option里的value值
换成form1.cars.options[form1.cars.selectedIndex].text
获取option的值