473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

unable to select an option from JavaScript drop down and onchange not called

in this below Java script drop down from Line.js, the onchange() is not called when i use mouse to select an option from drop down in mozilla environment. Even if I select an option the default one is reflecting. I was able to do the selections and it works well when I use key board up and down arrows followed by enter.
Where as in IE 8 it works well with mouse but not with keyboard.
Any quick solution will be highly appreciated.

Expand|Select|Wrap|Line Numbers
  1. this.myActivityButtonGui = slider.document.createElement("select");
  2.  
  3.       // this.myActivityButtonGui.options[this.myActivityButtonGui.options.length] = new Option("S", "C", false, false);
  4.       // this.myActivityButtonGui.options[this.myActivityButtonGui.options.length] = new Option("M", "M", false, false);
  5.       // this.myActivityButtonGui.options[this.myActivityButtonGui.options.length] = new Option("L", "R", false, false);
  6.       // this.myActivityButtonGui.options[this.myActivityButtonGui.options.length] = new Option("G", "G", false, false);
  7.       // this.myActivityButtonGui.options[this.myActivityButtonGui.options.length] = new Option("F", "F", false, false);
  8.  
  9.     var opt1 = document.createElement("option");
  10.     var opt2 = document.createElement("option"); 
  11.     var opt3 = document.createElement("option"); 
  12.     var opt4 = document.createElement("option");
  13.     var opt5 = document.createElement("option"); 
  14.  
  15.  
  16.     opt1.value = "C";  
  17.     opt1.text = "S";  
  18.     opt1.id= "C";
  19.  
  20.     opt2.value = "M"; 
  21.     opt2.text = "M";
  22.     opt2.id= "M";
  23.  
  24.     opt3.value = "R"; 
  25.     opt3.text = "L";
  26.     opt3.id = "R";
  27.  
  28.     opt4.value = "G"; 
  29.     opt4.text = "G";
  30.     opt4.id = "G";
  31.  
  32.     opt5.value = "F"; 
  33.     opt5.text = "F";
  34.     opt5.id= "F";
  35.  
  36.     if(browserType.indexOf("MSIE")!= -1){
  37.         this.myActivityButtonGui.add(opt1);
  38.         this.myActivityButtonGui.add(opt2);
  39.         this.myActivityButtonGui.add(opt3);
  40.         this.myActivityButtonGui.add(opt4);
  41.         this.myActivityButtonGui.add(opt5);
  42.     }else{
  43.         this.myActivityButtonGui.add(opt1,null);
  44.         this.myActivityButtonGui.add(opt2,null);
  45.         this.myActivityButtonGui.add(opt3,null);
  46.         this.myActivityButtonGui.add(opt4,null);
  47.         this.myActivityButtonGui.add(opt5,null);
  48.  
  49.     }
  50.  
  51.     this.myActivityButtonGui.onchange= function(){ // when i use //mouse with mozilla it is not coming into the loop that is onchange was //not fired.
  52.     slElement.value = this.options[this.selectedIndex].value;
  53. }
  54.  
Feb 9 '12 #1
1 1796
acoder
16,027 Expert Mod 8TB
Do you have a test page demonstrating the problem?

PS. don't use browser sniffing, use a try/catch to add options.
Feb 27 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Therese A. Sorna | last post by:
Hello all... I am using Access 2002, and am trying to find a way for a user to be able to select multiple entries from a drop-down list. I am hoping that given a list as such: a b c d
4
by: Sabra D via AccessMonster.com | last post by:
I have a db with 3 tables, owner, lessee, and tract, tract is the main table and has two lookup fields to find the owner and lessee info. My problem - i have a form with the owner info on top and...
4
by: deepee | last post by:
I have a drop down box in HTML using SELECT and OPTION tags: <select title="Choose a number" onchange="obscure()" name="Digit1" ID="Digit1"> <OPTION VALUE="">&nbsp;</OPTION> <OPTION...
1
by: Wayne Deleer | last post by:
Here's a perplexing thought... right now I'm writing an application that uses a web form, with many different input types. Some of these types are lists that allow for multiple selections. After...
1
by: anniyan1981 | last post by:
Need help very Urgent. I need to know how to select all the values in the Drop Down list by clciking a button. Please help me...
2
by: millertime90 | last post by:
Hi basically my problem is I have 2 drop down menus populated by my database the first populated by a field in the database and the 2nd populated with a relation to the value selected in the first...
1
by: sparksol | last post by:
I have a form with a drop down box. If you select an option in the drop down box (depending which option is selected) one or two textbox(es) and a submit button display. I would like to keep the...
13
by: ikilldeath | last post by:
Hi, I am very much new to JavaScript. Please, can anyone help in resolving this issue. Here in the example http://www.javascriptkit.com/script/script2/flipmenu.shtml There are two folders:...
3
by: vimal | last post by:
hi all, i am still a learner in javascript i have a select tag with options as follows: <select> <option py:for="mb in range(32,100)">${mb}</option> </select>
1
by: vidurac | last post by:
dear all, I want to dynamicaly write option values in drop down list using php. i use following code to do it. var x = document.getElementById("x_AreaName").value; x.options.text="text to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.