Solved

get selected option

Posted on 1997-12-29
7
396 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 200 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

705 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

22 Experts available now in Live!

Get 1:1 Help Now