faqts : Computers : Programming : Languages : JavaScript : Forms : SELECT

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

74 of 99 people (75%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

In a multiline select list (not multiple select), can I scroll a specific option into view (w/ both NN and IE)?

Dec 14th, 2006 06:11
Michael Seipp, ed sohn, Martin Honnen, Jeff Caesar,


There is no method, neither in any NN nor any IE version, to scroll a 
certain OPTION into view. IE however automatically scrolls the last 
selected OPTION into view. Hopefully NN6 will do the same.
Yes this is true.  However, (at least for i.e.- and may also for n.) 
you can set the 'select' property of an option to true to cause to 
scroll into view (given that this behaviour is acceptable)...  Else 
you can set it to true, then set it to false again in next line (which 
works for multiselect select boxes).
(MS):
you can use the following in IE
document.form_Name.select_Name.item
(document.form_Name.select_Name.selectedIndex).selected = true;
not sure of the result in NS/FF but try it.
(MS update 14/dec/2006) :
best pratice for cross browser (IE,FF,Opera etc.)
document.getElementById(thing).item(document.getElementById
(thing).selectedIndex).selected = true;
works everytime.