unidox Posted August 5, 2008 Share Posted August 5, 2008 I was wondering how I can do this: I have alot of options inside a select, and I need to have the values like: <option <? if($r['name'] == option value) { echo "selected = selected"; } ?> value = "John"> but the problem is, how can I find the value without typing the name in for each option. Thanks Quote Link to comment Share on other sites More sharing options...
niranjnn01 Posted August 5, 2008 Share Posted August 5, 2008 could you explain your requirement a little more?... Quote Link to comment Share on other sites More sharing options...
unidox Posted August 5, 2008 Author Share Posted August 5, 2008 Ok, I have a dropdown like this: <select name="name"> <option value="John"> </select> but I have over 400 options from the drop down. I was wondering if there was a way I can make it selected if the user already selected it. Because lets say I add a user, it adds the name John in the db. When I want to edit the user, I dont want to sort through all the names, I am trying to have it selected if the value matches the database. How can I do that? Thanks Quote Link to comment 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.