Get DropDownList Selected Details
印出DropDownList被选的资料
function Test()
{
var e = document.getElementById("");
var getOptionLength = e.options.length;
var getSelectedIndex = e.options[e.selectedIndex].value;
var getSelectedValue = e.options[e.selectedIndex].text;
var getSelected = e.options[e.selectedIndex].selected;
alert("Selected Index \t=\t" + getSelectedIndex +
"\r\nSelected Value \t=\t" + getSelectedValue +
"\r\nSelected Status \t=\t" + getSelected +
"\r\nOption Length \t=\t" + getOptionLength);
}
Remember Add OnChange In DropDownList
记得加OnChange在DropDownList
asp:DropDownList ID="myDrp" runat="server" AutoPostBack="false" OnChange="javascript:Test()"
===========================================================
Get Everyone DropDownList Selected Details
寻找DropDownList所有的资料
function Test2()
{
var e = document.getElementById("");
var getOptionLength = e.options.length;
for (var j = 0; j <>
{
var getSelectedIndex = e.options[j].value;
var getSelectedValue = e.options[j].text;
var getSelected = e.options[j].selected;
alert("Selected Index \t=\t" + getSelectedIndex +
"\r\nSelected Value \t=\t" + getSelectedValue +
"\r\nSelected Status \t=\t" + getSelected);
}
}
No comments:
Post a Comment