kathymack Posted November 24, 2012 Share Posted November 24, 2012 Hi I am using a combination of javascript and php. I use javascript to populate the country dropdown. For example if you selected united states, there is a state_prov dropdown list which updates to display a list of states, if you select Canada, the state_prov is populated with provinces and you select Australia, the state_prov dropdown list is hidden. This works great, except when the record is being added to a table, but when I have the modify form displaying I can't set the selectedIndex of the state_prov to the stateprov value I retreive from the table. Is there some Javascript code I can use to do this? I have renamed my functions.js to functions.txt so that it can be uploaded here. modify.php functions.txt Link to comment https://forums.phpfreaks.com/topic/271115-how-do-i-dynamically-set-the-selected-index-of-a-dropdown/ Share on other sites More sharing options...
codefossa Posted November 24, 2012 Share Posted November 24, 2012 Here's an example of this I've already done for someone. http://forums.phpfreaks.com/topic/270342-after-picking-us-or-canada-have-the-appropriate-states-or-provinces-show/ In the lower $.each, you could just do an if statement for the state of choice and set the selected attribute when you add the one you want. Link to comment https://forums.phpfreaks.com/topic/271115-how-do-i-dynamically-set-the-selected-index-of-a-dropdown/#findComment-1394787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.