mds1256 Posted December 31, 2012 Share Posted December 31, 2012 Hi I have a Title select box on my website (Mr, Mrs, Miss, etc). Now, if they enter something that does not meet the form validation, it reloads the page and populates the fields that has already been filled out along with the appropriate error message. Now my question is what is the best way to add the selected value that was chosen on the initial filled out form so they dont have to re-select. Quote Link to comment https://forums.phpfreaks.com/topic/272545-html-select-add-selected/ Share on other sites More sharing options...
Muddy_Funster Posted December 31, 2012 Share Posted December 31, 2012 check the value as it's being rendered and if it's the matching one from the previous submition add the selected="selected" to the option. Quote Link to comment https://forums.phpfreaks.com/topic/272545-html-select-add-selected/#findComment-1402347 Share on other sites More sharing options...
mds1256 Posted December 31, 2012 Author Share Posted December 31, 2012 check the value as it's being rendered and if it's the matching one from the previous submition add the selected="selected" to the option. Will that not mean there will be lots of if statements? Quote Link to comment https://forums.phpfreaks.com/topic/272545-html-select-add-selected/#findComment-1402348 Share on other sites More sharing options...
Muddy_Funster Posted December 31, 2012 Share Posted December 31, 2012 depends on how you are populating your select element, which without code I can't see Quote Link to comment https://forums.phpfreaks.com/topic/272545-html-select-add-selected/#findComment-1402352 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.