JS gets the value of the Drop-down list
| The code is as follows |
Copy Code |
| <fieldset> <label> type </label> <select name= "pid" id= ' pid ' > <option value= "0″> Please choose </option> <option value= "1″>php Learning Network </option> <option value= "2″>php Learning Network </option> </select> </fieldset> <fieldset> <label>php Learning Network </label> <select name= "SFK" id= ' SFK ' > <option value= "0″> Please choose </option> <option value= "0.3″>30%</option> <option value= "0.4″>40%</option> <option value= "0.5″>50%</option> <option value= "0.6″>60%</option> </select> </fieldset> <fieldset> <label>php Learning Network Http://www.111cn.net</label> <select name= "YFK" id= ' YFK ' > <option value= "0″> Please choose </option> <option value= "1″>1 year </option> <option value= "2″>2 year </option> <option value= "3″>3 year </option> <option value= "5″>5 year </option> </select> </fieldset> <fieldset> <label> </label> <input type= "button" onclick= "SIKP (' pid ', ' SFK ', ' yfk ')"/> </fieldset> </div> <script type= "Text/javascript" > function Sikp (p,s,y) { var pid = Getselval (P); var SFK = Getselval (s); var yfk = Getselval (y); window.open ("http://www.111cn.net" +PID+SFK+YFK); Link jumps to different places and adds that value } Get the value of a drop-down box function Getselval (ID) { var Objsel = document.getElementById (ID) var selval = Objsel.options[objsel.selectedindex].value; return selval; } </script> |
jquery Get Select:
Gets the text selected by select:
| The code is as follows |
Copy Code |
| $ ("#ddlRegType"). Find ("option:selected"). Text (); |
Gets the value selected by select:
| The code is as follows |
Copy Code |
| $ ("#ddlRegType"). Val (); |
Gets the index selected by select:
| The code is as follows |
Copy Code |
| $ ("#ddlRegType"). Get (0). SelectedIndex; |
Set Select:
Set the index selected by select:
| The code is as follows |
Copy Code |
| $ ("#ddlRegType"). Get (0). Selectedindex=index;//index |
to the index value