zeinaK Posted May 27, 2011 Share Posted May 27, 2011 Hi, A quick question please , I am trying to assign a selected index to a drop down list based on data retrieved from the database. I tried using JavaScript : document.getElementById('Country').selectedIndex =".$array['Country]."'; but it does work. Any suggestion? Quote Link to comment https://forums.phpfreaks.com/topic/237587-selected-index-and-drop-down-lists/ Share on other sites More sharing options...
eMonk Posted May 27, 2011 Share Posted May 27, 2011 I'd fetch the table info from mysql then use: <option <? if($row[column] == 'value') { echo "selected"; }?>>Value</option> Quote Link to comment https://forums.phpfreaks.com/topic/237587-selected-index-and-drop-down-lists/#findComment-1220897 Share on other sites More sharing options...
zeinaK Posted May 27, 2011 Author Share Posted May 27, 2011 Thank you, it works Quote Link to comment https://forums.phpfreaks.com/topic/237587-selected-index-and-drop-down-lists/#findComment-1220899 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.