monkey64 Posted June 17, 2007 Share Posted June 17, 2007 I do know that I can't use PHP with the onchange event as it's a Server Side language, not Client side like Javascript. I used the onchange event to describe what I want to do. Here we go! I have two drop-down boxes on my form which are populated dynamically from my database. Here's what I want to: 1. Pre-populate the first drop-down box from the database. 2. Make a selection. 3. When the onchange event occurs, populate the second drop-down box with a query based on the value from first one. There's a good example here: http://www.eurocarparts.com If you select a manufacturer, and click the button, the next drop-down gives you values only relevant to that manufacturer. It's really smart. Is it even possible using PHP? Any help would be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/55935-run-query-to-populate-a-drop-down-based-on-onchange-value-of-previous-drop-down/ Share on other sites More sharing options...
paul2463 Posted June 17, 2007 Share Posted June 17, 2007 its actually refreshing the whole page based upon a posted value for the new query to be run when you select a manufacturer and select go, it posts it back to itself a value for the next drop down such as you select "honda" and push go ->($_POST['manu']) if(isset($_POST['manu'])) { manu = $_POST['manu']; $query = "SELECT * FROM subheadings WHERE manufacturer = 'manu'"; *****code for making second drop down***** } and so on a so forth until all relevant drop downs are created Quote Link to comment https://forums.phpfreaks.com/topic/55935-run-query-to-populate-a-drop-down-based-on-onchange-value-of-previous-drop-down/#findComment-276245 Share on other sites More sharing options...
monkey64 Posted June 17, 2007 Author Share Posted June 17, 2007 "not always helpful, but always trying" Actually the code was VERY helpful. I now have a working example. Just couldn't get my head around it. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/55935-run-query-to-populate-a-drop-down-based-on-onchange-value-of-previous-drop-down/#findComment-276262 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.