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 -
function writeMenu(cPage)
-
{
-
/anny8.html" onclick="goNext(\'/ABC/anny8.html\'); return false">An(n)y Geocaching</a>/ '
-
if (cPage == "anny8")
-
{
-
document.getElementById("myMenu").innerHTML += '<select id="getNextGeoPage" onchange="navigate(this)" name="getNextGeoPage">;'
-
document.getElementById("myMenu").innerHTML += '</select> /'
-
}
-
-
document.getElementById("myMenu").innerHTML += '<a href="/ABC/index.html" onclick="goNext(\'/ABC/index.html\'); return false">An(n)y Home</a>/ '
-
document.getElementById("myMenu").innerHTML += '<a href="/SEC/testanny4.html" onclick="goNext(\'/SEC/testanny4.html\'); return false">An(n)y Testing</a>/ '
-
if (cPage == "anny8")
-
{
-
document.getElementById("getNextGeoPage").innerHTML = '<option value="" selected="selected">Select from archive</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2009">'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="21">January</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
-
document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2008">'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="18">December</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="13">November</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="7">October</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="5">September</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="1">August</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
-
}
-
-
}
-
Thinking it might have been a timing problem I also tried this method of loading the options. But it did not work either. -
function writeMenu(cPage)
-
{
-
/anny8.html" onclick="goNext(\'/ABC/anny8.html\'); return false">An(n)y Geocaching</a>/ '
-
if (cPage == "anny8")
-
{
-
document.getElementById("myMenu").innerHTML += '<select id="getNextGeoPage" onchange="navigate(this)" name="getNextGeoPage">;'
-
document.getElementById("myMenu").innerHTML += '</select> /'
-
}
-
-
document.getElementById("myMenu").innerHTML += '<a href="/ABC/index.html" onclick="goNext(\'/ABC/index.html\'); return false">An(n)y Home</a>/ '
-
document.getElementById("myMenu").innerHTML += '<a href="/SEC/testanny4.html" onclick="goNext(\'/SEC/testanny4.html\'); return false">An(n)y Testing</a>/ '
-
if (cPage == "anny8")
-
{
-
setTimeout("loadListBox()", 0);
-
}
-
}
-
function loadListBox()
-
{
-
document.getElementById("getNextGeoPage").innerHTML = '<option value="" selected="selected">Select from archive</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2009">'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="21">January</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
-
document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2008">'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="18">December</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="13">November</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="7">October</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="5">September</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="1">August</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
-
}
-
5 2955
It's a bug in IE. Use the DOM methods, e.g. options[] with new Option(), or createElement(), setAttribute(), appendChild(), or the add() method.
@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): - document.getElementById("getNextGeoPage").options[0] = new Option("Select from archive", "", true, true)
-
document.getElementById("getNextGeoPage").options[1] = new Option("<optgroup label="2009">'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="21">January</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
-
document.getElementById("getNextGeoPage").innerHTML += '<optgroup label="2008">'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="18">December</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="13">November</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="7">October</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="5">September</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '<option value="1">August</option>'
-
document.getElementById("getNextGeoPage").innerHTML += '</optgroup>'
-
For optgroup, you'd need to create an optgroup element and set its label: - var el = document.createElement("optgroup");
-
el.label = "2009";
and the options would be appended to the optgroup which in turn would be appended to the select element, e.g. - var opt = document.createElement('option');
-
opt.value = "21";
-
oOption.appendChild(document.createTextNode("January"));
-
// append the option to the option group
-
optGrp.appendChild(opt);
-
// append the option group to the select
-
sel.appendChild(optGrp);
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"? - var opt = document.createElement('option');
-
opt.value = "";
-
opt.appendChild(document.createTextNode("Select from archive"));
-
// append first option to the select
-
document.getElementById("getNextGeoPage").appendChild(opt);
-
-
//1. create option group for 2009
-
var optGrp = document.createElement("optgroup");
-
optGrp.label = "2009";
-
-
//2. define each options to option group for 2009
-
var opt = document.createElement("option");
-
opt.value = "21";
-
opt.appendChild( document.createTextNode("January") );
-
-
//3. append the option to the option group 2009
-
optGrp.appendChild(opt);
-
-
//4. append the option group 2009 to the page selector (this is done once for each year)
-
document.getElementById("getNextGeoPage").appendChild(optGrp);
-
-
//create option group 2008
-
var optGrp = document.createElement("optgroup");
-
optGrp.label = "2008";
-
-
//December
-
//add each month as an option (repeat next 4 lines for each option)
-
var opt = document.createElement("option");
-
opt.value = "18";
-
opt.appendChild( document.createTextNode("December") );
-
optGrp.appendChild(opt);
-
-
//November
-
var opt = document.createElement("option");
-
opt.value = "13";
-
opt.appendChild( document.createTextNode("November") );
-
// append the option to the option group
-
optGrp.appendChild(opt);
-
-
//October
-
var opt = document.createElement("option");
-
opt.value = "7";
-
opt.appendChild( document.createTextNode("October") );
-
// append the option to the option group
-
optGrp.appendChild(opt);
-
-
//September 2008
-
var opt = document.createElement("option");
-
opt.value = "5";
-
opt.appendChild( document.createTextNode("September") );
-
// append the option to the option group
-
optGrp.appendChild(opt);
-
-
//August 2008
-
var opt = document.createElement("option");
-
opt.value = "1";
-
opt.appendChild( document.createTextNode("August") );
-
// append the option to the option group
-
optGrp.appendChild(opt);
-
-
// append the option group to the select (this is done once for each year)
-
document.getElementById("getNextGeoPage").appendChild(optGrp);
-
-
// document.getElementById("getNextGeoPage").innerHTML = '<option value="" selected="selected">Select from archive</option>'
-
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": - // set property
-
opt.selected = true;
-
// alternatively, set the attribute:
-
opt.setAttribute("selected","selected");
Sign in to post your reply or Sign up for a free account.
Similar topics
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:...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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: 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: 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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
| |