I was glad to see this question posted as I previously thought it wasn't possible. This brings me to my next question, can you select multiple options from a select box upon loading a page? Thanks
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
posted
0
Yes, if "MULTIPLE" is specified in the SELECT clause, it will apear as a list box, and you should be able to have more than one selected items.
Bosun
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Tom Hopkins
Greenhorn
Joined: Aug 10, 2001
Posts: 14
posted
0
Bosun, Thanks for your reply, but I don't think I worded my question properly. I do indeed have MULTIPLE as an attribute to the SELECT tag and as such a user can of course select multiple options from the list box. My question was related to a post from yesterday wherein someone asked how to select options in a list box from javascript (ie. so that when the page loads certain options are already selected). Further posts indicated using something similar to document.formName.selectBoxName.selectedIndex = n; which works for selecting ONE item from a list box. I wanted to know if anyone knows of a way to select multiple options from javascript. I hope this makes sense.
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
posted
0
Did you try something like this? var select = document.formName.selectName; select.options[i].selected = true; select.options[j].selected = true; Bosun
Tom Hopkins
Greenhorn
Joined: Aug 10, 2001
Posts: 14
posted
0
Son of a Gun - it worked. Very cool. I hate to be a bother, but how would I select a radio button. I know only one can be selected at a time, I'm just wondering how to select from javascript. Thanks
Tom Hopkins
Greenhorn
Joined: Aug 10, 2001
Posts: 14
posted
0
Found my own answer to this one. document.formName.selectName[i].checked = true;