[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 selected value 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 pass 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 selected by select
Gets the text: $ ("#ddlregtype") selected by select. Find ("option:selected"). Text ();
Gets the value: $ ("#ddlregtype") selected by select. Val ();
Gets the index selected by 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 get the selected value and text from the following script code s[JavaScript]View Plain Copy $ ("#mySelect"). Val (); Gets the value value of the selected record $ ("#mySelect option:selected"). Text (); Gets the text value of the selected record
2, the use of 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, delete all options option[JavaScript]View plain copy var obj = document.getElementById ("Myselect"); obj.options.length = 0;
4, Delete selected options 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 Selected Response Event[JavaScript]View Plain Copy $ ("#mySelect"). Change (function () {//Add action code to be performed})