Forums

pre-selected option in select box

jrthor2 06 Feb, 2011
If I have a select box, and I want it to be "pre-selected", and then if there is an error on the page, have the option the user selected as "selected", how would I do this? I tried putting a selected="selected" attribute on the option i wanted "Pre-selected", but if I choose an option from the select box that is before this "pre-selected" option, then the option that I hardcoded to being selected is what is selected when an error occurs. How can I do this with having the option the user selected as being "selected" when an error occurs.

Thanks!
GreyHead 06 Feb, 2011
Hi jrthor2,

The simplest way is to put your 'preselected' option as the first option wiithout using selected='selected'. Then if nothing else is selected this option will be returned.

Otherwise it would probably need a JavaScript snippet to handle adding (or removing) the pre-selection. The ChronoForms 'republish' code isn't clever enough to notice and remove a default selection.

Bob
This topic is locked and no more replies can be posted.