?
Solved

get selected option

Posted on 1997-12-29
7
Medium Priority
?
428 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
  • 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
Technology Partners: 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

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!

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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

615 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