Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. <html>
  2. <body>
  3. <form name="doublecombo" form action"index.php" method="POST">
  4. <p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
  5. <option>Amazon</option>
  6. <option>Apple</option>
  7. <option>Logitech</option>
  8. <option>Nike</option>
  9. </select>
  10. <select name="stage2" size="1">
  11. <option value="http://javascriptkit.com">Kindle Fire</option>
  12. <option value="http://www.news.com">Kindle DX</option>
  13. <option value="http://www.wired.com">Kindle Charger</option>
  14. <option value="http://www.microsoft.com">Kindle Paperweight</option>
  15. </select>
  16. <input type="button" name="test" value="Generate"
  17. onClick="gen()">
  18. </p>
  19.  
  20. <script>
  21. var groups=document.doublecombo.example.options.length
  22. var group=new Array(groups)
  23. for (i=0; i<groups; i++)
  24. group[i]=new Array()
  25.  
  26. group[0][0]=new Option("Kindle Fire","http://javascriptkit.com")
  27. group[0][1]=new Option("Kindle DX","http://www.news.com")
  28. group[0][2]=new Option("Kindle Charger","http://www.wired.com")
  29. group[0][2]=new Option("Kindle Paperweight","http://www.microsoft.com")
  30.  
  31. group[1][0]=new Option("MacBook","http://www.cnn.com")
  32. group[1][1]=new Option("iPhone","http://www.abcnews.com")
  33. group[1][2]=new Option("iPad","http://www.yahoo.com")
  34. group[1][3]=new Option("iMac","http://www.apple.com")
  35.  
  36. group[2][0]=new Option("G602 Wireless Gaming Mouse","http://www.hotbot.com")
  37. group[2][1]=new Option("G19s Gaming Keyboard","http://www.infoseek.com")
  38. group[2][2]=new Option("G430 Surround Sound Gaming Headset","http://www.excite.com")
  39. group[2][3]=new Option("PowerShell Controller","http://www.lycos.com")
  40.  
  41. group[3][0]=new Option("Nike FuelBand","http://www.nike.com")
  42.  
  43. var temp=document.doublecombo.stage2
  44.  
  45. function redirect(x){
  46. for (m=temp.options.length-1;m>0;m--)
  47. temp.options[m]=null
  48. for (i=0;i<group[x].length;i++){
  49. temp.options[i]=new Option(group[x][i].text,group[x][i].value)
  50. }
  51. temp.options[0].selected=true
  52. }
  53.  
  54. function gen(){
  55. location=temp.options[temp.selectedIndex].value
  56. }
  57.  
  58. function exampleFunction(){
  59. }
  60.  
  61. function anotherExampleFunction(){
  62. }
  63. </script>
  64.  
  65. </form>
  66. </html>
  67. </body>
  68.  
  69. $(selector).on('click', gen);
  70. $(selector).on('change', redirect);
  71.  
  72. $(selector).click(gen);
  73. $(selector).change(redirect);
  74.  
  75. var functions = {
  76. func1: function(){console.log("func1 called")},
  77. func2: function(){console.log("func2 called")},
  78. func3: function(){console.log("func3 called")},
  79. }
  80.  
  81. $( "select" )
  82. .change(function () {
  83. var selected = $( "select option:selected" );
  84. functions[selected.val()]();
  85. })
  86. .change();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement