[HTML] View plain copy <script src= "jquery.min.js" type= "Text/javascript" ></script> <script language= "JavaScript" type= "Text/javascript" > $ (document). Ready (function () { $ (' #mySelect '). Change (function () { alert ($ (this). Children (' option:selected '). Val ()); var p1=$ (this). Children (' option:selected '). Val ();//This is the value of selected var p2=$ (' # Param2 '). Val ();//Get the value of other labels on this page window.location.href= "xx.php?param1=" +p1+ "¶m2=" +p2+ "";//page jump and send parameter ) }) </script> <select id= "Myselect" > <option value= "1" >one</option> <option value= "2" selected = "Selected" >two</option> <option value= "3" >three</option> < /select> <input type= "text" value= "ooo" name= "param2" id= "param2"/>& nbsp;
jquery Gets the text and value of select selection
Gets the Select selected text: $ ("#ddlregtype"). Find ("option:selected"). Text ();
Gets the Select selected value: $ ("#ddlregtype"). Val ();
Gets the selected index of select: $ ("#ddlregtype"). Get (0). SelectedIndex;
1. Get the value and text,html code for select Select as follows:[HTML]View plain copy <select id= "Myselect" > <option value= "1" >one</option> <option value= "2" >two< ;/option> <option value= "3" >three</option> </select>
You can use the following script code s to get the selected value and text[JavaScript]View Plain Copy $ ("#mySelect"). Val (); Gets the value of the selected record $ ("#mySelect option:selected"). Text (); Gets the text value of the selected record
2. Use new option ("Text", "value") method to add Options option[JavaScript]View plain copy var obj = document.getElementById ("Myselect"); Obj.add (New Option ("4", "4")); 3. Remove all options option[JavaScript]View plain copy var obj = document.getElementById ("Myselect"); obj.options.length = 0;
4. Delete selected option[JavaScript]View plain copy var obj = document.getElementById ("Myselect"); var index = Obj.selectedindex; Obj.options.remove (index);
5. Modify the selected options option[JavaScript]View plain copy var obj = document.getElementById ("Myselect"); var index = Obj.selectedindex; Obj.options[index] = new Option ("three", 3); Change the corresponding value obj.options[index].selected = true; Remain selected
6. Delete Select[JavaScript]View plain copy var obj = document.getElementById ("Myselect"); Obj.parentNode.removeChild (obj); Remove Current Object
7. Select Response Events[JavaScript]View Plain Copy $ ("#mySelect"). Change (function () {//Add the action code needed to execute})