JS獲取DropDownList的value值與text值的示例代碼
更新時間:2014年01月07日 09:29:23 作者:
本篇文章主要是對JS獲取DropDownList的value值與text值的示例代碼進行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助
相關JS:
<script type="text/javascript" language="javascript">
function SearchChange()
{
var ddl = document.getElementById("DropDownList1")
var index = ddl.selectedIndex;
var Value = ddl.options[index].value;
var Text = ddl.options[index].text;
alert(Value);
}
</script>
調(diào)用:
<asp:DropDownList ID="DropDownList1" runat="server" onchange="SearchChange();">
<asp:ListItem Value="0">111</asp:ListItem>
<asp:ListItem Value="1">222</asp:ListItem>
<asp:ListItem Value="2">333</asp:ListItem>
</asp:DropDownList
復制代碼 代碼如下:
<script type="text/javascript" language="javascript">
function SearchChange()
{
var ddl = document.getElementById("DropDownList1")
var index = ddl.selectedIndex;
var Value = ddl.options[index].value;
var Text = ddl.options[index].text;
alert(Value);
}
</script>
調(diào)用:
復制代碼 代碼如下:
<asp:DropDownList ID="DropDownList1" runat="server" onchange="SearchChange();">
<asp:ListItem Value="0">111</asp:ListItem>
<asp:ListItem Value="1">222</asp:ListItem>
<asp:ListItem Value="2">333</asp:ListItem>
</asp:DropDownList
您可能感興趣的文章:
- JS簡單操作select和dropdownlist實例
- JS,Jquery獲取select,dropdownlist,checkbox下拉列表框的值(示例代碼)
- js給dropdownlist添加選項的小例子
- 用javascript為DropDownList控件下拉式選擇添加一個Item至定義索引位置
- 客戶端用JavaScript填充DropDownList控件 服務器端讀不到值
- asp.net省市三級聯(lián)動的DropDownList+Ajax的三種框架(aspnet/Jquery/ExtJs)示例
- JavaScript與DropDownList 區(qū)別分析
- 利用js給DropdownList賦值實例
相關文章
layer ui插件顯示tips時,修改字體顏色的實現(xiàn)方法
今天小編就為大家分享一篇layer ui插件顯示tips時,修改字體顏色的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09javascript 兼容FF的onmouseenter和onmouseleave的代碼
經(jīng)過測試發(fā)現(xiàn),例子1 在 ff下抖動的厲害,ie下稍微有點。 具體原因 其實就是 mouseout 的冒泡機制 引起的。2008-07-07JS實現(xiàn)PC手機端和嵌入式滑動拼圖驗證碼三種效果
這篇文章主要介紹了JS實現(xiàn)PC手機端和嵌入式滑動拼圖驗證碼三種效果,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-02-028個開發(fā)者必須知道的JavaScript深層概念(推薦)
JavaScript有一個名為“調(diào)用堆?!保–all Stack)的簡單列表,它逐一管理任務(堆棧算法),但是當異步任務被傳遞時,JavaScript會把它彈出到web API,瀏覽器就會處理它,這篇文章主要介紹了8個開發(fā)者必須知道的JavaScript深層概念,需要的朋友可以參考下2022-10-10詳解Js 根據(jù)文件夾目錄獲取Json數(shù)據(jù)輸出demo
這篇文章主要為大家介紹了Js 根據(jù)文件夾目錄獲取Json數(shù)據(jù)輸出示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-03-03詳解如何通過JavaScript實現(xiàn)函數(shù)重載
這篇文章主要為大家詳細介紹了如何通過JavaScript實現(xiàn)函數(shù)重載,文中的示例代碼講解詳細,對我們學習JavaScript有一定的幫助,感興趣的可以了解一下2023-01-01