473,232 Members | 1,682 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,232 software developers and data experts.

options not loading in IE

Claus Mygind
571 512MB
The following code loads fine in fireFox but does not load in IE. The list box loads but the options in the list box fail to load

Expand|Select|Wrap|Line Numbers
  1. function writeMenu(cPage)
  2. {
  3. /anny8.html" onclick="goNext(\'/ABC/anny8.html\'); return false">An(n)y Geocaching</a>/&nbsp;'
  4.     if (cPage == "anny8")
  5.     {
  6.         document.getElementById("myMenu").innerHTML +=  '<select id="getNextGeoPage" onchange="navigate(this)" name="getNextGeoPage">;'
  7.         document.getElementById("myMenu").innerHTML +=  '</select>&nbsp;/'
  8.     }
  9.  
  10.     document.getElementById("myMenu").innerHTML +=  '<a href="/ABC/index.html" onclick="goNext(\'/ABC/index.html\'); return false">An(n)y Home</a>/&nbsp;'
  11.     document.getElementById("myMenu").innerHTML +=  '<a href="/SEC/testanny4.html" onclick="goNext(\'/SEC/testanny4.html\'); return false">An(n)y Testing</a>/&nbsp;'
  12.     if (cPage == "anny8")
  13.     {
  14.         document.getElementById("getNextGeoPage").innerHTML  = '<option value="" selected="selected">Select from archive</option>'
  15.         document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2009">'
  16.         document.getElementById("getNextGeoPage").innerHTML += '<option value="21">January</option>'
  17.         document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
  18.         document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2008">'
  19.         document.getElementById("getNextGeoPage").innerHTML += '<option value="18">December</option>'
  20.         document.getElementById("getNextGeoPage").innerHTML += '<option value="13">November</option>'
  21.         document.getElementById("getNextGeoPage").innerHTML += '<option value="7">October</option>'
  22.         document.getElementById("getNextGeoPage").innerHTML += '<option value="5">September</option>'
  23.         document.getElementById("getNextGeoPage").innerHTML += '<option value="1">August</option>'
  24.         document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
  25.     }
  26.  
  27. }
  28.  
Thinking it might have been a timing problem I also tried this method of loading the options. But it did not work either.
Expand|Select|Wrap|Line Numbers
  1. function writeMenu(cPage)
  2. {
  3. /anny8.html" onclick="goNext(\'/ABC/anny8.html\'); return false">An(n)y Geocaching</a>/&nbsp;'
  4.     if (cPage == "anny8")
  5.     {
  6.         document.getElementById("myMenu").innerHTML +=  '<select id="getNextGeoPage" onchange="navigate(this)" name="getNextGeoPage">;'
  7.         document.getElementById("myMenu").innerHTML +=  '</select>&nbsp;/'
  8.     }
  9.  
  10.     document.getElementById("myMenu").innerHTML +=  '<a href="/ABC/index.html" onclick="goNext(\'/ABC/index.html\'); return false">An(n)y Home</a>/&nbsp;'
  11.     document.getElementById("myMenu").innerHTML +=  '<a href="/SEC/testanny4.html" onclick="goNext(\'/SEC/testanny4.html\'); return false">An(n)y Testing</a>/&nbsp;'
  12.     if (cPage == "anny8")
  13.     {
  14.     setTimeout("loadListBox()", 0);
  15.     }
  16. }
  17. function loadListBox()
  18. {
  19.         document.getElementById("getNextGeoPage").innerHTML  = '<option value="" selected="selected">Select from archive</option>'
  20.         document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2009">'
  21.         document.getElementById("getNextGeoPage").innerHTML += '<option value="21">January</option>'
  22.         document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
  23.         document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2008">'
  24.         document.getElementById("getNextGeoPage").innerHTML += '<option value="18">December</option>'
  25.         document.getElementById("getNextGeoPage").innerHTML += '<option value="13">November</option>'
  26.         document.getElementById("getNextGeoPage").innerHTML += '<option value="7">October</option>'
  27.         document.getElementById("getNextGeoPage").innerHTML += '<option value="5">September</option>'
  28.         document.getElementById("getNextGeoPage").innerHTML += '<option value="1">August</option>'
  29.         document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
  30. }
  31.  
Jan 21 '09 #1
5 2945
acoder
16,027 Expert Mod 8TB
It's a bug in IE. Use the DOM methods, e.g. options[] with new Option(), or createElement(), setAttribute(), appendChild(), or the add() method.
Jan 22 '09 #2
Claus Mygind
571 512MB
@acoder
Ok thanks for your reply, but I am stuck again as I was when I previously posted "Dynamic Option Group" thread. A little sample code would be very helpful here.

Here is my partial attempt to load the list box with options. Corrections to this code would be very much appreciated (as is clearly visible in the code I am stuck on line 2):
Expand|Select|Wrap|Line Numbers
  1.     document.getElementById("getNextGeoPage").options[0] = new Option("Select from archive", "", true, true)
  2.     document.getElementById("getNextGeoPage").options[1] = new Option("<optgroup label="2009">'
  3.     document.getElementById("getNextGeoPage").innerHTML += '<option value="21">January</option>'
  4.     document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
  5.     document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2008">'
  6.     document.getElementById("getNextGeoPage").innerHTML += '<option value="18">December</option>'
  7.     document.getElementById("getNextGeoPage").innerHTML += '<option value="13">November</option>'
  8.     document.getElementById("getNextGeoPage").innerHTML += '<option value="7">October</option>'
  9.     document.getElementById("getNextGeoPage").innerHTML += '<option value="5">September</option>'
  10.     document.getElementById("getNextGeoPage").innerHTML += '<option value="1">August</option>'
  11.     document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
  12.  
Jan 22 '09 #3
acoder
16,027 Expert Mod 8TB
For optgroup, you'd need to create an optgroup element and set its label:
Expand|Select|Wrap|Line Numbers
  1. var el = document.createElement("optgroup");
  2. el.label = "2009";
and the options would be appended to the optgroup which in turn would be appended to the select element, e.g.
Expand|Select|Wrap|Line Numbers
  1. var opt = document.createElement('option');
  2. opt.value = "21";
  3. oOption.appendChild(document.createTextNode("January"));
  4. // append the option to the option group
  5. optGrp.appendChild(opt);
  6. // append the option group to the select
  7. sel.appendChild(optGrp);
Jan 22 '09 #4
Claus Mygind
571 512MB
Thank you very much. I was able to complete the list box with your sample code and gain some knowledge in the process. Just one aspect I am not sure about, my first option on the select box is a blank option asking the user to make a selection. While not necessary here, I would like to know how to add it anyway. The default property of "Selected = Selected"

// document.getElementById("getNextGeoPage").innerHTM L = '<option value="" selected="selected">Select from archive</option>'

Since I am creating a object "var opt" and then assigning attributes to the object "opt.value = ..."

Can I then assign the following "opt.selected = "selected"?

Expand|Select|Wrap|Line Numbers
  1.         var opt = document.createElement('option');
  2.         opt.value = "";
  3.         opt.appendChild(document.createTextNode("Select from archive"));
  4.         // append first option to the select
  5.         document.getElementById("getNextGeoPage").appendChild(opt);
  6.  
  7.         //1. create option group for 2009
  8.         var optGrp = document.createElement("optgroup");
  9.         optGrp.label = "2009";
  10.  
  11.         //2. define each options to option group for 2009 
  12.         var opt = document.createElement("option");
  13.         opt.value = "21";
  14.         opt.appendChild( document.createTextNode("January") );
  15.  
  16.         //3. append the option to the option group 2009
  17.         optGrp.appendChild(opt);
  18.  
  19.         //4. append the option group 2009 to the page selector (this is done once for each year)
  20.         document.getElementById("getNextGeoPage").appendChild(optGrp);
  21.  
  22.         //create option group 2008
  23.         var optGrp = document.createElement("optgroup");
  24.         optGrp.label = "2008";
  25.  
  26.         //December
  27.         //add each month as an option (repeat next 4 lines for each option)
  28.         var opt = document.createElement("option");
  29.         opt.value = "18";
  30.         opt.appendChild( document.createTextNode("December") );
  31.         optGrp.appendChild(opt);
  32.  
  33.         //November
  34.         var opt = document.createElement("option");
  35.         opt.value = "13";
  36.         opt.appendChild( document.createTextNode("November") );
  37.         // append the option to the option group
  38.         optGrp.appendChild(opt);
  39.  
  40.         //October
  41.         var opt = document.createElement("option");
  42.         opt.value = "7";
  43.         opt.appendChild( document.createTextNode("October") );
  44.         // append the option to the option group
  45.         optGrp.appendChild(opt);
  46.  
  47.         //September 2008
  48.         var opt = document.createElement("option");
  49.         opt.value = "5";
  50.         opt.appendChild( document.createTextNode("September") );
  51.         // append the option to the option group
  52.         optGrp.appendChild(opt);
  53.  
  54.         //August 2008
  55.         var opt = document.createElement("option");
  56.         opt.value = "1";
  57.         opt.appendChild( document.createTextNode("August") );
  58.         // append the option to the option group
  59.         optGrp.appendChild(opt);
  60.  
  61.         // append the option group to the select (this is done once for each year)
  62.         document.getElementById("getNextGeoPage").appendChild(optGrp);
  63.  
  64. //        document.getElementById("getNextGeoPage").innerHTML  = '<option value="" selected="selected">Select from archive</option>'
  65.  
Jan 23 '09 #5
acoder
16,027 Expert Mod 8TB
If you want it selected and you're using elem.selected syntax, then you need to set it to true. If you set the attribute, you can set it to "selected":
Expand|Select|Wrap|Line Numbers
  1. // set property
  2. opt.selected = true;
  3. // alternatively, set the attribute:
  4. opt.setAttribute("selected","selected");
Jan 23 '09 #6

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

Similar topics

3
by: Roy Wang | last post by:
hi, My problem is how to determining when the XML file has loaded using javascript. I loaded an xml file using javascript in a web page. The code below is loading the xml file for IE:...
3
by: RC | last post by:
I can't quite grasp the concept of creating custom reports depending upon what options a user picks on a Form. For example, the user clicks on a "Print Reports" button and a Form pops up. On the...
6
by: Curious George | last post by:
I have a page that takes about 10 seconds to load the first time it is run. I would like to first display a little animated gif telling the user that the page is loading. How do I do this with...
3
by: m* | last post by:
Hi all... I would like to have an options form with my application that the user can set different settings. I have the form, now to save the information, is it best to save to a text file? Or...
4
by: Benton | last post by:
Hi there, I have a child webform (with a ASP.NET calendar control) that opens in a javascript popup window when I click a button in the caller form. Child page has a <title> tag, and javascript...
8
by: Andrew Robert | last post by:
Hi Everyone. I tried the following to get input into optionparser from either a file or command line. The code below detects the passed file argument and prints the file contents but the...
11
by: Bit Byte | last post by:
I am trying to create a multi-tabbed 'dialog' box (similar to the one displayed when Tools->Options is selected in most MS Office apps). Ofcourse, this is for a website, so I'm not sure if i can...
1
by: Sendil kumar | last post by:
Hi All, I have a C++ apllication which in turn loads the jvm. When the JVM is loaded it turns off my crash handler filter and sets its own filter by default, so, when ever a crash happens I was...
0
by: BigRedEO | last post by:
I am trying to run the "source" command against a script with almost 5,000 LOAD statements - and nothing but LOAD statements - no other mysql statements in the script. The command works, however,...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.