473,322 Members | 1,778 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,322 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 2955
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,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.