在JavaScript中获取asp DropDownList的选定值 [英] Get Selected Value of asp DropDownList in Javascript

查看:53
本文介绍了在JavaScript中获取asp DropDownList的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个简短的问题.我有一个带有asp:Dropdownlist控件的网页.如何在JavaScript中获取此下拉列表的SelectedValue?

例如:var value = document.GetElementById(DDL).Value

Hi all, i have a quick question. I have a webpage that has an asp:Dropdownlist control. How can i get the SelectedValue of this dropdownlist in my javascript?

e.g: var value = document.GetElementById(DDL).Value

推荐答案

var ddl = document.getElementById("<%=DDL.ClientID%>");
var SelVal = ddl.options[ddl.selectedIndex].text;
alert(SelVal); //SelVal is the selected Value


参考
1.使用asp.net中的JavaScript 获取dropdownlist的selectedvalue [ ^ ]
2. 在javascript中获取asp:dropdownlist的选定值: [^ ]


Reference
1. get selectedvalue of dropdownlist using javascript in asp.net[^]
2. Get selected value of asp:dropdownlist in javascript:[^]


我得到了解决方案在这里 ...
I got the solution here...


尝试以下代码:
Try below code:
var e = document.getElementById("ddlLocation");  
var selectedLocation = e.options[e.selectedIndex].value; 


这篇关于在JavaScript中获取asp DropDownList的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆