Solved

get selected option

Posted on 1997-12-29
7
410 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

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!

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

733 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