cbrooks Posted November 19, 2009 Share Posted November 19, 2009 I have a input screen where one of the inputs is selected via the following dropdown <code> $query="select customer_nbr, cust_name from web05a"; $result=pg_query($sqlconnection, $query); $rows=pg_num_rows($result); echo "<tr><td align='right'>Associated Company:</td>"; echo "<td><select name='ucompany'>"; for ($i=0;$i<$rows;$i++){ $row=pg_fetch_array($result); $cname=$row['customer_nbr']." : ".$row['cust_name']; echo "<option value='{$row['customer_nbr']}'>$cname</option>"; } echo "</select>"; </code> This dropdown works great, my problem is that I need to have a second drop down immediately following this one whery my db query would depend on the value comming from the first dropdown. my second query would be as follows: $query="select ship_nbr, ship_name, ship_line from web06a where customer_nbr=VALUE FROM THE FIRST DROPDOWN From the resulting table I would then fill in the second dropdown list Help will be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/ Share on other sites More sharing options...
MadTechie Posted November 19, 2009 Share Posted November 19, 2009 See a old example Dynamic DropDown PHP/AJAX Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/#findComment-961142 Share on other sites More sharing options...
cbrooks Posted November 19, 2009 Author Share Posted November 19, 2009 OK, I see where the function is getting the info selected, but 'Just Call Me Slow' but I need you to explain how that gets me anywhere closer to filling in the second dropdown on the fly? Some I need more of a slap in the head and then a very hard push, instead of a gentle bump!!! Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/#findComment-961183 Share on other sites More sharing options...
MadTechie Posted November 19, 2009 Share Posted November 19, 2009 If you read the notes and comments, you should see, try the single file example and play with it, any problem just let me know. Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/#findComment-961339 Share on other sites More sharing options...
cbrooks Posted November 19, 2009 Author Share Posted November 19, 2009 OK, I got that to work and here is where I am: Just working within the code that you pointed me to: changed their first drop down so that it loads from my database table as per the origninal code that I mentioned. It works ok. Now, when I select a record from the drop down list and click on the 'Submit' button it does load the second drop down list as I require and I can select an item from it. So far so good! Now, I guess my problem now is with the <form> Once I have selected an item from each drop down, then that info needs to be passed to another program which updates another database table with the selected info. This <form> sends to $_POST to its self, so how do I get the info to the next step? Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/#findComment-961373 Share on other sites More sharing options...
MadTechie Posted November 19, 2009 Share Posted November 19, 2009 Now, when I select a record from the drop down list and click on the 'Submit' button it does load the second drop down list as I require and I can select an item from it. So far so good! You shouldn't have to click submit, This <form> sends to $_POST to its self, so how do I get the info to the next step? You can change the form to post anywhere, as it doesn't affect the drop downs, as they are controlled via ajax Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/#findComment-961478 Share on other sites More sharing options...
cbrooks Posted November 20, 2009 Author Share Posted November 20, 2009 OK, if I understand you correctly, then if I copy the code from the pointed to topic, copy it to my site, run it as is then it should work! I select something from the first drop down and something will then appear in the second drop down allowimg me to select something from it??? If that is what is supposed to happen, then it ain't happening on my end. I tried the version that required no database and then tried the one using a database with same results. My understanding is that I select something from first drop down and it then uses that result to place items in the second drop down???? Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/#findComment-961969 Share on other sites More sharing options...
MadTechie Posted November 20, 2009 Share Posted November 20, 2009 Can you try it here as it seams okay to me, (I have included a get source code like as well) Test me Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/#findComment-962062 Share on other sites More sharing options...
cbrooks Posted November 20, 2009 Author Share Posted November 20, 2009 That is working just as expected. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/182165-drop-down-help/#findComment-962075 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.