Solved

selectedIndex focus

Posted on 2000-04-18
4
216 Views
Last Modified: 2008-01-09
Hiyas,
Is there a way to scroll to  the selectedIndex of a select list if it's not being shown in the visible rows? I'm using size="4" on the <select> and the option list is much longer than that.

I'm building the list and setting a 'selected' option with ASP.  That's all fine.  The correct option is showing up highlighted...it's just not immediately visible sometimes.

This has to work in Netscape too by the way.
0
Comment
Question by:WrrX
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2725856
Not possible in netscape - known bug.

In IE the
document.myForm.mySelect.selectedIndex = 10;
should scroll to the 10th entry

Michel
0
 
LVL 1

Accepted Solution

by:
Faxe earned 75 total points
ID: 2726591
Since you're working with asp, why don't you try working around it by changing the sort order of the multiple select box.
the items marked that are selected are places at the top of the list instead of at their regular position (like alphabetical)...

<OPTION SELECTED>3</OPTION>
<OPTION SELECTED>6</OPTION>
<OPTION SELECTED>9/OPTION>
<OPTION> </OPTION>
<OPTION>1</OPTION>
<OPTION>2</OPTION>
<OPTION>4</OPTION>
<OPTION>5</OPTION>
<OPTION>7</OPTION>
<OPTION>8</OPTION>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2727055
Hmm - and use javascript to rewrite the order of the select on later changes... If the user won't be confused about the order - why not...

Michel
0
 

Author Comment

by:WrrX
ID: 2728804
Sometimes the most obvious things escape me :)  Thanks for the extra info too Michel.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now