?
Solved

get selected option

Posted on 1997-12-29
7
Medium Priority
?
418 Views
Last Modified: 2009-12-16
I have a selection form on my page. When a user selects something by mouseclick, the list minimizes but doesn't loose focus. So I can't get the selected option before the user clicks somewhere else, because the onBlur-event doesn't occur and the selectedIndex isn't updated earlier.
Is there any way to get the selected option without the user has to click something else?
0
Comment
Question by:borsdorf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:nanullnet
ID: 1277227
Yes, use the onChange handler.
0
 

Author Comment

by:borsdorf
ID: 1277228
Sorry, that's not the solution, because the Change-event doesn't occur before the object looses focus.
0
 
LVL 6

Expert Comment

by:tecbuilder
ID: 1277229
When the form is created you already know what the selected item is because you set this initially.  When the user changes the selection you use the onChange event to determine what the current selectedindex is.  The only way the selectedindex would change then is if the user clicks on one (or more) items of the selection list.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:borsdorf
ID: 1277230
May be, I didn't ask precisly enough. (Please excuse my bad english.) Normally, after selecting something from the selection list, the user has to click somewhere OUTSIDE of the select object (OK-button for example), because otherwise the select object doesn't loose its focus and the selectedIndex is not updated. What I want is that the user ONLY has to click the desired item and nothing else. Any idea?
0
 
LVL 1

Accepted Solution

by:
nanullnet earned 600 total points
ID: 1277231
Not true borsdorf.  You say that when "the list minimizes" you are refering to a multiple select.  When you click on any other item than the currently selected (or default) in that list, the onChange handler is tripped irregardless of whether the user ever moves his mouse again.  I use this in countless pages, so saying it doesn't work just does not cut it.  If you disagree, please post code and I will fix it.
0
 

Author Comment

by:borsdorf
ID: 1277232
Meanwhile I understood that I have a compatibility problem only. I tried my sample on different browsers and operating systems and found that the problem only happens on Navigator 2.x and 3.x under Windows 3.11. On other browser or OS the select object looses focus when the user selects something by mouseclick.

So my questions becomes harder: Is there any solution for Navigator 3 under Win 3.11?
0
 
LVL 1

Expert Comment

by:nanullnet
ID: 1277233
Unfortunately, if the Browser does not support it, there is little you can do to keep it the same.  The only workaround I know of is to have a button next to the select bar, that the user must click.  You can have that appear only for windows 3.1 users if you like, and let 32 bit users benefit from the ease of the onChange.  Code for detection is as follows:

if (navigator.appName == "Netscape Navigator" && parseFloat(navigator.appVersion) < 4 && navigator.appVersion.lastIndexOf('Win16') != -1) {
}
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…
Suggested Courses

762 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