1: DropDownList
------------------------------------------------- -----------------------------------------------
When using JQuery to perform traversal operations,
$("input").each(function(i) {
......
}
When the type of the operation object is dropdownlist: (Note: The type of DropDownList in Firefox is "select-one")
Get the selected value: $(this).val(); (If it is not a traversal operation, $(this) is replaced with $( '#The Id of the control') )
Get the selected text: $(this).find("option:selected").text(); or $("#The name of the control option:selected").text( );
Get the selected index: $(this).get(0).selectedIndex;
2: RadioButtonList
------------------- -------------------------------------------------- -----------------------
If the page has only one RadioButtonList, you can directly use $("input[type='radio']:checked") .val() to get the selected value
If the page has 2 or more RadioButtonLists:
Step 1: Get the Id of the RadioButtonList control, set var objId=controlId;
Second Step: Get the name of the control, set var radioName = $("input[id^='" objId "']").eq(0).attr('name');
Step 3: Get the value
Get the selected value: $("input[name='" radioName "']:checked").val());
Get the selected text: $("input[name='" radioName "']:checked label").text());
Three: CheckBoxList
----------------------- -------------------------------------------------- ------------------
There is a method to determine whether there is a selection, objId is the Id of CheckBoxList
Currently it is not possible to directly obtain the value of the server control CheckBoxList using js. , can only be achieved through some small tricks, such as adding additional attributes
In the code, selectedText is to get the selected text value, and selectedValue is to get the selected value