-
Scrolling a Select
Anyone know a quick official way to scroll a multiple-selection SELECT to the seleted item at page load (option is dynamically picked by server-side script, out of potentially hundreds of choices)? I don't see anything in the W3 DOM, but I could be overlooking it.
I don't need to support anything less than 6.0 browsers, BTW, but I do need to be compliant with the W3 (because its stupid not too when you don't need to support older browsers). It's not that big a deal if there isn't - it's for a small bit of user friendlyness, not anything critical.
Thanks.
-
If you just want a way to select a particular option in a select box then I think you can do it for example like this:
SelectId.selectedIndex=5
Sorry if that's not what you want. :p
-
No, the script writes the "selected" to the desired option tag as the options are being pulled from the database. What happens is the the list has the first 15 items or so visible, but if the 30th item was selected, its not apparent to the user until they scroll down the list. I'd like it to autmatically scroll to the selected item at page load, if there's an item selected.
Thanks anyway.
-
I very often find myself dissapointed with the select combo box, and I play with different way to mimic one with divs. The user doesn't even need to know that it isn't a real form element, except in this case, where I don't know how to mimic the scroll bar and manipulate it.
If you are fine with the idea of using little arrow images to trigger scrolling and not have a bar, then you could set up a div to act like your form element.
You make a div and style it to look like a combo box. You fill it with spans, each one being a single selectable item.
An onClick event for the spans can swap the colors to highlight it.
A down arrow image can have an onClick even to "scroll" the items in the div. It will remove the top span and add a new one to the bottom. Might work better with onMouseDown onMouseUp so they can hold it down.
Anyway, I'm just tossing out ideas. I haven't played with some of these, but I would think they would all be possible.
(wow, my grammar is just horrible today)
-
Hmm - I kinda wrote the code as a function that's reused on multiple pages, so I'm kinda stuck with <option> tags. It's not that critical to need to rewrite anything at this point. Thanks anyway.