javascript获得下拉列表的值
我是新手!!<scriptid="clientEventHandlersJS"language="javascript"><!--functionButton1_oncl...
我是新手!!
<script id="clientEventHandlersJS" language="javascript">
<!--
function Button1_onclick(Select1) {
var t=window.document.testForm.Select1.options[window.document.testForm.Select1.selectedIndex].text;
alert(t);
}
//-->
</script>
<form id="testForm" method="post">
<SELECT id="Select1" name="Select1">
<OPTION selected value="111">11111111111</OPTION>
<OPTION value="222">22222222222</OPTION>
<OPTION value="333">33333333333</OPTION>
<OPTION value="444">44444444444</OPTION>
</SELECT>
<INPUT id="Button1" type="button" value="Button" name="Button1" onclick="return Button1_onclick()">
</form> 展开
<script id="clientEventHandlersJS" language="javascript">
<!--
function Button1_onclick(Select1) {
var t=window.document.testForm.Select1.options[window.document.testForm.Select1.selectedIndex].text;
alert(t);
}
//-->
</script>
<form id="testForm" method="post">
<SELECT id="Select1" name="Select1">
<OPTION selected value="111">11111111111</OPTION>
<OPTION value="222">22222222222</OPTION>
<OPTION value="333">33333333333</OPTION>
<OPTION value="444">44444444444</OPTION>
</SELECT>
<INPUT id="Button1" type="button" value="Button" name="Button1" onclick="return Button1_onclick()">
</form> 展开
2008-04-22
展开全部
给你一段代码,我测试过了
<script>
function show(){
alert(document.myform.mysel.options[document.myform.mysel.selectedIndex].text);
}
</script>
<form name="myform">
<select name="mysel" onchange="show()">
<option value="1">上海</option>
<option value="2" selected="selected">天津</option>
<option value="3">北京</option>
</select>
</form>
<script>
function show(){
alert(document.myform.mysel.options[document.myform.mysel.selectedIndex].text);
}
</script>
<form name="myform">
<select name="mysel" onchange="show()">
<option value="1">上海</option>
<option value="2" selected="selected">天津</option>
<option value="3">北京</option>
</select>
</form>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询