<script type="text/javascript" language="javascript">
function getDDLData() {
var data = document.getElementById("<%=DropDownList1.ClientID %>");//根据DropDownList的客户端ID获取该控件
var typeValue = data.options[data.selectedIndex].value;//获取DropDownList当前选中值
alert(typeValue);//测试
}
}
</script>
本文介绍了一个JavaScript函数getDDLData(),该函数通过客户端ID获取一个名为DropDownList1的控件,并返回其当前选中项的值。此方法适用于网页应用程序中动态获取下拉列表的选择结果。
905

被折叠的 条评论
为什么被折叠?



