jasonlepak Posted October 14, 2011 Share Posted October 14, 2011 I'm currently working on an Auto Parts Inventory script with four selectable options... Year, Make, Model and Engine After choosing those options I plan on having it display interchangeable parts such as exhaust, brakes, etc... That we already have in stock. So far I have the database started, and a simple dropdown menu working... But what I'd like is a menu like the one I have posted here, yet I can't find any samples or scripts for it. Anyone have any suggestions or anything that'll help me out? This is what I want... This is what I have so far... http://www.jasonlepak.com/test2 Quote Link to comment https://forums.phpfreaks.com/topic/249086-ajax-php-and-mysql-menu/ Share on other sites More sharing options...
teynon Posted October 14, 2011 Share Posted October 14, 2011 Lol, you've got all of that. Just add multiple to the select statements. IE <select size=10 multiple><option value="blah">Vrroom</option></select> My guess is you cut and pasted that script since you don't know how to make them multiple? Quote Link to comment https://forums.phpfreaks.com/topic/249086-ajax-php-and-mysql-menu/#findComment-1279501 Share on other sites More sharing options...
jasonlepak Posted October 15, 2011 Author Share Posted October 15, 2011 To a point you're right... I don't sit in front of my computer all day "programming" or trying to bash someone for using another persons FREE example or helpful scripts. Though in turn, I did take a very simple two dropdown menu script and turn it into what I have right now... And I plan on writing the rest of the script to make it into what I need it to be. Will I visit a few sites to get examples or to get ideas along the way? Hell Yes. I won't say that when it comes to database scripts I can start everything from scratch... But how many people actually can unless they went to school for it and/or do it 24/7? I have a real job where I actually get my hands dirty. So when I'm done working at the end of the day, do you think I want to spend the rest of it in front my computer to learn everything there is to know about php, mysql, ajax, flash or any other language there is to know? Is this site not intended for people to help others? Am I not making the effort to learn something new by asking someone that's not a smartass behind a keyboard for some help with something that I've obviously haven't done before? Quote Link to comment https://forums.phpfreaks.com/topic/249086-ajax-php-and-mysql-menu/#findComment-1279544 Share on other sites More sharing options...
jasonlepak Posted October 15, 2011 Author Share Posted October 15, 2011 And to add to the code that you tried helping me with... It's not simple HTML... It's PHP, MySQL and AJAX. There is a database where I'm manually typing in every piece of information that you see when you use the dropdown menu's. There's a seperate file for connecting to the database. There's a function.php file that has most of the backend information. And there's an index.php file for the front end. The following is a part of the func.php file for one of the dropdowns... if($_GET['func'] == "drop_1" && isset($_GET['func'])) { drop_1($_GET['drop_var']); } function drop_1($drop_var) { include_once('db.php'); $result = mysql_query("SELECT DISTINCT tier_two FROM three_drops WHERE tier_one='$drop_var' ORDER BY tier_two") or die(mysql_error()); echo '<select name="drop_2" id="drop_2"> <option value=" " disabled="disabled" selected="selected">Choose Make</option>'; while($drop_2 = mysql_fetch_array( $result )) { echo '<option value="'.$drop_2['tier_two'].'">'.$drop_2['tier_two'].'</option>'; } echo '</select>'; echo "<script type=\"text/javascript\"> $('#wait_2').hide(); $('#drop_2').change(function(){ $('#wait_2').show(); $('#result_2').hide(); $.get(\"func.php\", { func: \"drop_2\", drop_var: $('#drop_2').val() }, function(response){ $('#result_2').fadeOut(); setTimeout(\"finishAjax_tier_three('result_2', '\"+escape(response)+\"')\", 400); }); return false; }); </script>"; } And the following is my html file <?php include('db.php'); include('func.php'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Year, Make, Model and Engine</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val() }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { $('#wait_1').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } function finishAjax_tier_three(id, response) { $('#wait_2').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } /* function finishAjax_tier_three(id, response) { $('#wait_3').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } */ function finishAjax_tier_four(id, response) { $('#wait_3').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } </script> <style type="text/css"> <!-- body { background-color: #666666; } .style1 {color: #000000} --> </style></head> <body> <h1 align="center"><em>Vehicle Year, Make, Model and Engine size</em></h1> <h1 class="style1"> </h1> <p> <form action="" method="post"> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select Year</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> <span id="wait_2" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_2" style="display: none;"></span> <span id="wait_3" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_3" style="display: none;"></span> <span id="wait_4" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_4" style="display: none;"></span> </form> </p> <p> <?php if(isset($_POST['submit'])){ $drop = $_POST['drop_1']; $drop_2 = $_POST['drop_2']; $drop_3 = $_POST['drop_3']; $drop_4 = $_POST['drop_4']; echo "You selected a "; // echo $drop_3." ".$drop." ".$drop_4." ".$drop_2; echo $drop." ".$drop_2." ".$drop_3." ".$drop_4; echo "<br>"; echo "Aren't you special..."; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/249086-ajax-php-and-mysql-menu/#findComment-1279547 Share on other sites More sharing options...
teynon Posted October 15, 2011 Share Posted October 15, 2011 It's simple HTML. Just because your system is complex doesn't change that. Your HTML is in your javascript / PHP Change echo '<select name="drop_2" id="drop_2"> to echo '<select name="drop_2" id="drop_2" size=10> Quote Link to comment https://forums.phpfreaks.com/topic/249086-ajax-php-and-mysql-menu/#findComment-1279601 Share on other sites More sharing options...
jasonlepak Posted October 15, 2011 Author Share Posted October 15, 2011 Thank you. Your help worked. Quote Link to comment https://forums.phpfreaks.com/topic/249086-ajax-php-and-mysql-menu/#findComment-1279602 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.