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? 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> 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 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
Archived
This topic is now archived and is closed to further replies.