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?
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <script type="text/javascript" src="jquery-1.3.2.js"></script>
- <script type="text/javascript">
- $("document").ready(function(){
- $("#make").attr("disabled","disabled");
- $("#model").attr("disabled","disabled");
- $("#year").change(function(){
- $("#make").attr("disabled","disabled");
- $("#make").html("<option>wait...</option>");
- $("#model").html("<option>wait...</option>");
- var id = $("#year option:selected").attr('value');
- $.post("select_type.php", {id:id}, function(data){
- $("#make").removeAttr("disabled");
- $("#make").html(data);
- });
- });
-
- $("#make").change(function(){
- $("#model").attr("disabled","disabled");
- $("#model").html("<option>wait...</option>");
- var id = $("#make option:selected").attr('value');
- $.post("select_model.php", {id:id}, function(data){
- $("#model").removeAttr("disabled");
- $("#model").html(data);
- });
- });
- /*THIS IS WHERE I WOULD LIKE TO SEND THE FORM DATA (Year, Make & Model) TO handleForm.php FILE*/
- $("form#select_form").submit(function(){
- var year = $("#year option:selected").attr('value');
- var make = $("#make option:selected").attr('value');
- var model = $("#model option:selected").attr('value');
- if(year>0 && make>0)
- {
- var result = $("#model option:selected").html();
- $("#result").html('your choice: '+result);
- }
- else
- {
- $("#result").html("you must choose two options!");
- }
- return false;
- });
- });
- </script>
- </head>
- <body>
- <?php include "select.class.php"; ?>
- <form id="select_form">
- Choose a Year:<br />
- <select id="year"> <!--SELECTING A YEAR-->
- <?php echo $opt->ShowYear(); ?>
- </select>
- <br /><br />
- Choose a Make:<br />
- <select id="make"> <!--SELECTING A MAKE-->
- <?php echo $opt->ShowModel(); ?>
- <!--<option value="0">choose...</option>-->
- </select>
- <br /><br />
- Choose a Model:<br />
- <select id="model"> <!--SELECTING A MODEL-->
- <option value="0">choose...</option>
- </select>
- <br /><br />
- <input type="submit" value="confirm" />
- </form>
- <div id="result"></div>
- </body>
- </html>