function Initnetcode () {var html = ""; $.ajax ({type: "Post", Async:false, url: "User/inituserform.do", Data: "Method=getprovinc E ", DataType:" JSON ", success:function (data) {if (data!= 0) {var temp = Ev
Al (data); for (var i = 0; i < temp.length i++) {html = "<option value= '" + Temp[i].netid + "' >" + te
Mp[i].netcode + "</option>";
} else {html = ' <option> network exception </option> ';
}
}
});
alert (HTML); $ (HTML). Appendto ("#f_netCode")} jquery to select operation/traversal option and Add, remove option function Changeshipmethod (shipping) {VA R len = $ ("select[@name =ishiptype]option"). Length if (shipping.value!= "CA") {$ ("select[@name =ishiptype]option"). each
(function () {if ($ (this). Val () ==111) {$ (). remove ();
}
}); }else{$ ("<optionvalue= ' >upsgro")Und</option> "). Appendto ($ (" select[@name =ishiptype] "));
}//Get the selection value of the Drop-down menu $ (#testSelect option:selected '). Text ();
or $ ("#testSelect"). Find (' option:selected '). Text ();
or $ ("#testSelect"). Val (); A bad memory can be collected under: 1, dropdown box: var cc1 = $ (". formcselect[@ Name= ' country '] "option[@selected]"). Text ()//(note that there are spaces in the middle) var CC2 = $ ('. formcselect[@name = "Country"]). Val (); The value of the selected item of the Drop-down menu is obtained var CC3 = $ ('. FORMC select[@name = ' country '] '). attr ("id");//Get the id attribute value of the selected item of the Drop-down menu $ ("#select"). empty ();
Empty the Drop-down box//$ ("#select"). html ('); $ ("<optionvalue= ' 1 ' >1111</option>"). Appendto ("#select")//Add dropdown box to explain a little bit: 1.select[@name = '
Country '] option[@selected] represents the option element with the selected attribute in the Select element with the name attribute and the value ' country '; you can see that a @ begins with a property. 2, Radio Box: $ ("input[@type =radio][@checked]"). Val (); Gets the value of the selected item in the Radio box (note that there are no spaces in the middle) $ ("input[@type =radio][@value =2]"). attr ("Checked", ' checked '); Set the Radio box value=2 is selected. (Note that there are no spaces in the middle) 3, check box: $ ("input[@type =checkbox][@checked] "). Val (); Gets the value of the first item selected in the check box $ ("input[@type =checkbox][@checked]"). each (function () {//The check box is typically selected for more than one, so you can loop out alert ($ (this). val
());
}); $ ("#chk1"). attr ("Checked", "")//Do not tick $ ("#chk2"). attr ("Checked", true);/tick if ($ ("#chk1"). attr (' checked ') = = Undefined) {}//To determine if a check has been ticked of course the jquery selector is powerful.
There are many other ways. <script src= "Jquery-1.2.1.js" type= "Text/javascript" ></script> <script language= "javascript" type= "
Text/javascript "> $ (document). Ready (function () {$ (" #selectTest "). Change (function () {//alert (" Hello ");
Alert ($ ("#selectTest"). attr ("name"));
$ ("a"). attr ("href", "xx.html");
Window.location.href= "xx.html";
Alert ($ ("#selectTest"). Val ());
Alert ($ ("#selectTest option[@selected]"). text ());
$ ("#selectTest"). attr ("Value", "2");
});
});
</script> <ahref= "#" >aaass</a> <!--dropdown box--> <select id= "selecttest" name= "Selecttest" >
<optionvalue= "1" >11</option> <optionvalue= "2" >22</option><optionvalue= "3" >33</option> <optionvalue= "4" >44</option> <optionvalue= "5" >55</ Option> <optionvalue= "6" >66</option> </select> jqueryradio value, checkbox value, select Value, Radio selected,
CheckBox selected, select selected, and related to get a set of radio selected value var item = $ (' input[@name =items][@checked] '). Val ();
Gets the text of the Select selected item var item = $ ("select[@name =items] option[@selected]"). Text ();
The second element of the Select Drop-down box is the currently selected value $ (' #select_id ') [0].selectedindex = 1;
The second element of the radio Radio Group is the currently selected value $ (' input[@name =items] '). Get (1). checked = true; Get Value: text box, text area: $ ("#txt"). attr ("value"), multiple-selection box checkbox:$ ("#checkbox_id"). attr ("value"); Select Group Radio: $ ("input[@type =radio
] [@checked] "). Val ();
Dropdown box Select: $ (' #sel '). Val (); Control form elements: text box, text area: $ ("#txt"). attr ("Value", ""),//Empty contents $ ("#txt"). attr ("value", ' 11 ');/Fill multiple-selection box checkbox: $ ("#chk 1 "). attr (" Checked "," "),//Do not tick $ (" #chk2 "). attr (" Checked ", true);/tick if ($ (" #chk1 "). attr (' Checke d ') ==undefined//Determine if the radio:$ ("input[@type =radio]" has been ticked. attr ("checked", ' 2 '); The item to set value=2 is the Drop-down box select:$ (" #sel ") for the current selection. attr (" value ", '-sel3 ');//Set VALUE=-SEL3 item is the current check $ (" <optionval Ue= ' 1 ' >1111</option><optionvalue= ' 2 ' >2222</option> '). Appendto ("#sel")//Add drop-down Box option $ ("#se
L "). Empty ()//Empty dropdown box Gets the value of a set of radio selected items = $ (' input[@name =items][@checked] '). Val ();
Gets the text of the Select selected item var item = $ ("select[@name =items] option[@selected]"). Text ();
The second element of the Select Drop-down box is the currently selected value $ (' #select_id ') [0].selectedindex = 1;
The second element of the radio Radio Group is the currently selected value $ (' input[@name =items] '). Get (1). checked = true; Get Value: text box, text area: $ ("#txt"). attr ("value"), multiple-selection box checkbox:$ ("#checkbox_id"). attr ("value"); Select Group Radio: $ ("input[@type =radio
] [@checked] "). Val ();
Dropdown box Select: $ (' #sel '). Val (); Control form elements: text box, text area: $ ("#txt"). attr ("Value", "");/empty contents $ ("#txt"). attr ("value", ' 11 ');//Fill Multiple-selection box checkbox: $ ("#chk1"). attr ("Checked", "")//Not Tick $ ("#chk2"). attr ("Checked", true);/tick if ($ ("#chk1"). attr (' checked ') ==undefined)// Determine if you have checked the selected group radio:$ ("input[@type =radio]"). attr ("Checked", ' 2 ');//Set value=2 item is currently selectedItem dropdown box select:$ ("#sel"). attr ("value", '-sel3 ');//Set VALUE=-SEL3 item to current check $ ("<optionvalue= ' 1 ' >1111</option
><optionvalue= ' 2 ' >2222</option> "). Appendto (" #sel ")//Add Option $ (" #sel ") to the Drop-down box. Empty ()//Empty Drop-down box