Jquery Newbie, Dynamic dropdown menu submission

Jquery Newbie, Dynamic dropdown menu submission

Hello I'm very new to JQuery and I'm working on a script that is a form with a Chained or Dependent dropdown menu for Year, Make & Model selector that is MySQL/PHP - JQuery. I'm at the point were I can select all of the dropdowns but I'm stuck on how to send that data over to a php script (handleIndex.php) I would like to get the values that are selected and use some type of $_GET statement to redirect to the new URL with the selected values appended like ( handleIndex.php?year=year&make=make&model=model ) . I will include the script below. Can someone point me in the right direction please?


  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3.     <head>
  4.     <script type="text/javascript" src="jquery-1.3.2.js"></script>
  5.     <script type="text/javascript">
  6.         $("document").ready(function(){
  7.             $("#make").attr("disabled","disabled");
  8. $("#model").attr("disabled","disabled");
  9.             $("#year").change(function(){
  10. $("#make").attr("disabled","disabled");
  11. $("#make").html("<option>wait...</option>");
  12. $("#model").html("<option>wait...</option>");
  13. var id = $("#year option:selected").attr('value');
  14. $.post("select_type.php", {id:id}, function(data){
  15. $("#make").removeAttr("disabled");
  16. $("#make").html(data);
  17. });
  18. });
  19. $("#make").change(function(){
  20. $("#model").attr("disabled","disabled");
  21. $("#model").html("<option>wait...</option>");
  22. var id = $("#make option:selected").attr('value');
  23. $.post("select_model.php", {id:id}, function(data){
  24. $("#model").removeAttr("disabled");
  25. $("#model").html(data);
  26. });
  27. });
  28. /*THIS IS WHERE I WOULD LIKE TO SEND THE FORM DATA (Year, Make & Model) TO handleForm.php FILE*/
  29. $("form#select_form").submit(function(){
  30. var year = $("#year option:selected").attr('value');
  31. var make = $("#make option:selected").attr('value');
  32. var model = $("#model option:selected").attr('value');
  33. if(year>0 && make>0)
  34. {
  35. var result = $("#model option:selected").html();
  36. $("#result").html('your choice: '+result);
  37. }
  38. else
  39. {
  40. $("#result").html("you must choose two options!");
  41. }
  42. return false;
  43. });
  44. });
  45.     </script>
  46.     </head>
  47.     <body>
  48.         <?php include "select.class.php"; ?>
  49.         <form id="select_form">
  50.             Choose a Year:<br />
  51.             <select id="year"> <!--SELECTING A YEAR-->
  52.                 <?php echo $opt->ShowYear(); ?>
  53.             </select>
  54.         <br /><br />
  55.         Choose a Make:<br />
  56.         <select id="make"> <!--SELECTING A MAKE-->
  57.          <?php echo $opt->ShowModel(); ?>
  58.              <!--<option value="0">choose...</option>-->
  59.         </select>
  60.         <br /><br />
  61.         Choose a Model:<br />
  62.         <select id="model"> <!--SELECTING A MODEL-->
  63.              <option value="0">choose...</option>
  64.         </select>
  65.         <br /><br />
  66.         <input type="submit" value="confirm" />
  67.         </form>
  68.         <div id="result"></div>
  69.     </body>
  70. </html>