centenial Posted May 26, 2006 Share Posted May 26, 2006 Hi,I have a dropdown list similiar to this:[code]<select name="dropdown"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>[/code]Now, in my database table I have a field called 'dropdown' and in it is one of those values (Let's say "3" for an example). Now, on my edit page I want to display that dropdown (select) list but have the correct item selected. Like this (For example):[code]<select name="dropdown"><option value="1">1</option><option value="2">2</option><option value="3" selected>3</option><option value="4">4</option><option value="5">5</option></select>[/code]Now if I change it to "2", "5", or any other option next time I go to the edit page the correct item should be selected. How should I go about doing this? Is there an easy function that accomplishes it?Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/10544-select-correct-item-from-dropdown-list/ Share on other sites More sharing options...
nogray Posted May 27, 2006 Share Posted May 27, 2006 The easiest way is to add the value as the first options like this (if three is selected)[code]<select name="dropdown"><option value="3">3</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10544-select-correct-item-from-dropdown-list/#findComment-39340 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.