I have drop down list with four values: value1-4 User is can get to that page by clicking one of four links that are related to values in drop down. Link1->Value1 etc
Now each of the links pointing to that page contains variable ([url]http://.......icon=value1[/url])
I would like value in drop down on page load to auto select depending on url. How can I do that?
thanks
auto select value in drop down on page load
How is the dropdown HTML code generated, i.e. is it dynamic or static? The general idea would be: for each option in the dropdown, check if that option's value is equal to the value the user previously selected and, if it is, output the necessary HTML (e.g. selected="selected") to make that option be selected by default.
be more specific, give us examples what do you expect.
You might want to look at: http://www.w3.org/TR/html401/interact/forms.html#h-17.6.1
(Note: the simple addition of "selected" used to work and should indeed work but doesn't anymore on FF and Chrome)
The answer from there is pretty straight forward. Add ' selected="selected"' to the option you want selected.
"selected" should work in HTML documents while "selected" is wrong for XHTML documents and in the XHTML serialization of HTML 5 where it should be 'selected="selected"'. Still, both FF and Chrome works fine with simply "selected" on OSX, not only using 4.01 doctype as specified above (which as I understand it has no bearing on documents served in an HTML 5 browser since they will treat those as HTML 5 docs anyway - most likely with the exception of IE - and most likely with options to "downgrade" behaviour to that of others...) but also with HTML 5 wether serialized as html or xml.