compguru910 Posted July 5, 2008 Share Posted July 5, 2008 Ok, here I am again with another question that, if I could get answered would save me alot of time. Heres the scenario if you woud... On my crime stoppers website, you have the option to add a crime through forms and a database, easy, right. Well, when the user wants to add a crime to the website, they have to select from this drop down menu/list box, the type of crime it is. This list box's values are all dynamic because the types of the crimes are stored in another table so that as the need arises, instead of having me add a type of crime through code, and updating every page that has this list box, they can add it themselves. Well. The problem arises when they go to make a change to a crime that they added, how do I make it so that the type of crime they selected, is still selected when they get to the page. I was wondering if anyone has ran into this before and found a solution. Thanks in advance guys. Quote Link to comment https://forums.phpfreaks.com/topic/113325-dynamic-list-box-selected-help/ Share on other sites More sharing options...
PC Nerd Posted July 5, 2008 Share Posted July 5, 2008 your database should be holding an ID for the Crime Type: original form would hold the value as the type ID, ( or name), and display the name On the form that your editing with. when looping through crime types - you just need to compare against eh database first ( assumign youve already got eh user data out: echo "<option value ='".$CrimeType...... "; if($Crime_Type['Type_ID'] == $Data['Crime_Type']) { echo "selected = 'selected' "; } gdlk Quote Link to comment https://forums.phpfreaks.com/topic/113325-dynamic-list-box-selected-help/#findComment-582235 Share on other sites More sharing options...
compguru910 Posted July 5, 2008 Author Share Posted July 5, 2008 Tahnk you, I will give that one a try. Quote Link to comment https://forums.phpfreaks.com/topic/113325-dynamic-list-box-selected-help/#findComment-582252 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.