Specify a default selected item for HTML form drop-downs

nefreyu

New Member
Typically when you need to select an item by default, you do:\[code\]<select> <option value="http://stackoverflow.com/questions/3608359/1"> Volvo </option> <option value="http://stackoverflow.com/questions/3608359/2" selected="true"> Saab </option> <option value="http://stackoverflow.com/questions/3608359/3"> Mercedes </option> <option value="http://stackoverflow.com/questions/3608359/4"> Audi </option></select>\[/code\]Is it possible to get something like this?\[code\]<select selectedValue="http://stackoverflow.com/questions/3608359/2"> <option value="http://stackoverflow.com/questions/3608359/1"> Volvo </option> <option value="http://stackoverflow.com/questions/3608359/2"> Saab </option> <option value="http://stackoverflow.com/questions/3608359/3"> Mercedes </option> <option value="http://stackoverflow.com/questions/3608359/4"> Audi </option></select>\[/code\]It works out easier in PHP since you only have to soft-code one value, instead of handling the selected attribute on any possible \[code\]<option/>\[/code\].
 
Back
Top