Referring to the previous post by Eric, does anybody know a way that I can set the selected option if I know its value?
For example, I have a subCategory value that�s being passed back from a
Servlet as a request attribute and would like to set the relevant option as selected.
The array is declared as follows:
selectOptions['SHEETS'] = new Array('Choose a sub category','Flat', 'Centre Folded', 'Multi Folded');
On loading the page, I want to assign the option 'Flat' as being selected within the following code:
//Create a new option (text,value)
var newOpt = new Option(selectOptions[selectedItem][i], selectOptions[selectedItem][i]);
//append it to the options list
sel.options[sel.options.length] = newOpt;
Any help or guidance will be appreciated.
Thanks very much.