D
Disco-181
Hi,
I have a script which isn't working in Mozilla based browser for some
reason. I'm trying to run two functions from the body onload tag and
it simply isn't happening.
I have a cascading menu, where the primary dropdown selection
determines the contents of a second dropdown. This is triggered by a
function in the onchange tag of the primarys select tag. When
triggered like this, the function and drop downs work fine. When
returning to the page I query a database to maintain state of the
primary dropdown and use the onload to trigger the function used in
the onchange to repopulate the second dropdown. As I say this works
fine in IE etc but not Mozilla based browsers.
Here's the code snippets. Anyone got any ideas?
In the header:
<script type="text/javascript">
function doOnload() {
selectInterests(form1)
preloadImages()
}
</script>
<script language="JavaScript">
function selectInterests(frm)
{
// Obtain the first dimension position of the currently selected
var i = frm.adv_category.selectedIndex;
var n = frm.adv_interests.selectedIndex;
if (i > 0){
// Inititalise the new adv_interests selection
frm.adv_interests.options.length = arrValInterests.length
- 1;
// Now select the the items associated with the selected
option
for (var j=1; j < arrValInterests.length; j++){
frm.adv_interests.options[j-1].text =
arrTextInterests[j];
frm.adv_interests.options[j-1].value =
arrValInterests[j];
}
frm.adv_interests.options[0].selected = true;
}
else{
// User has reselected the blank 'adv_interests' option
frm.adv_interests.options.length = 1;
frm.adv_interests.options[0].text ="--Please Select--
";
frm.adv_interests.options[0].value = "";
}
}
</script>
</head>
<body bgcolor="#FFFFFF" onLoad="doOnload();" leftmargin="0"
topmargin="0" marginwidth="0" marginheight="0">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
In the body:
<SELECT NAME="adv_category"
ID="adv_category"onChange="selectInterests(form1);">
<option value="0">--Please Select--</option>
<option value="3">Banknotes</option>
<option value="5" selected>Books</option>
<option value="1">Coins</option>
<option value="4">Medals</option>
<option value="6">Numismatic Circular</option>
</SELECT>
<SELECT multiple size="10" NAME="adv_interests" ID="adv_interests"
style="width:350px;">
<option value="">--Please Select--</option>
</SELECT>
<script language="JavaScript">
var arrValInterests = new Array();
var arrTextInterests = new Array();
arrValInterests[0] = new Array("0","0");
arrTextInterests[0] = new Array("0","--All Categories--");
arrValInterests[1] = new
Array("3","0","752","...removed...","724","653","654");
arrTextInterests[1] = new Array("3","--All
Categories--","Abyssinia","Afghanistan","...removed...","USA","Venezuela","Vietnam","West
Indies","Yemen","Yugoslavia","Zanzibar");
arrValInterests[2] = new Array("5","0","661","...removed...","662");
arrTextInterests[2] = new Array("5","--All Categories--","British
Coins-All","...removed...","Sylloge of Coins of the British Isles");
arrValInterests[3] = new Array("1","...removed...","36");
arrTextInterests[3] = new Array("1","--All
Categories--","...removed...","Treasure","US Coins");
arrValInterests[4] = new Array("4","0","121","...removed...","384");
arrTextInterests[4] = new Array("4","--All Categories--","British
orders","...removed...","Single Campaign Medals");
arrValInterests[5] = new Array("6","0");
arrTextInterests[5] = new Array("6","--All Categories--");
</script>
<script language="JavaScript">
function selectInterests(frm)
{
// Obtain the first dimension position of the currently selected
var i = frm.adv_category.selectedIndex;
var n = frm.adv_interests.selectedIndex;
if (i > 0){
// Inititalise the new adv_interests selection
frm.adv_interests.options.length = arrValInterests.length - 1;
// Now select the the items associated with the selected option
for (var j=1; j < arrValInterests.length; j++){
frm.adv_interests.options[j-1].text = arrTextInterests[j];
frm.adv_interests.options[j-1].value = arrValInterests[j];
}
frm.adv_interests.options[0].selected = true;
}
else
{
// User has reselected the blank 'adv_interests' option
frm.adv_interests.options.length = 1;
frm.adv_interests.options[0].text ="--Please Select-- ";
frm.adv_interests.options[0].value = "";
}
} </script>
I have a script which isn't working in Mozilla based browser for some
reason. I'm trying to run two functions from the body onload tag and
it simply isn't happening.
I have a cascading menu, where the primary dropdown selection
determines the contents of a second dropdown. This is triggered by a
function in the onchange tag of the primarys select tag. When
triggered like this, the function and drop downs work fine. When
returning to the page I query a database to maintain state of the
primary dropdown and use the onload to trigger the function used in
the onchange to repopulate the second dropdown. As I say this works
fine in IE etc but not Mozilla based browsers.
Here's the code snippets. Anyone got any ideas?
In the header:
<script type="text/javascript">
function doOnload() {
selectInterests(form1)
preloadImages()
}
</script>
<script language="JavaScript">
function selectInterests(frm)
{
// Obtain the first dimension position of the currently selected
var i = frm.adv_category.selectedIndex;
var n = frm.adv_interests.selectedIndex;
if (i > 0){
// Inititalise the new adv_interests selection
frm.adv_interests.options.length = arrValInterests.length
- 1;
// Now select the the items associated with the selected
option
for (var j=1; j < arrValInterests.length; j++){
frm.adv_interests.options[j-1].text =
arrTextInterests[j];
frm.adv_interests.options[j-1].value =
arrValInterests[j];
}
frm.adv_interests.options[0].selected = true;
}
else{
// User has reselected the blank 'adv_interests' option
frm.adv_interests.options.length = 1;
frm.adv_interests.options[0].text ="--Please Select--
";
frm.adv_interests.options[0].value = "";
}
}
</script>
</head>
<body bgcolor="#FFFFFF" onLoad="doOnload();" leftmargin="0"
topmargin="0" marginwidth="0" marginheight="0">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
In the body:
<SELECT NAME="adv_category"
ID="adv_category"onChange="selectInterests(form1);">
<option value="0">--Please Select--</option>
<option value="3">Banknotes</option>
<option value="5" selected>Books</option>
<option value="1">Coins</option>
<option value="4">Medals</option>
<option value="6">Numismatic Circular</option>
</SELECT>
<SELECT multiple size="10" NAME="adv_interests" ID="adv_interests"
style="width:350px;">
<option value="">--Please Select--</option>
</SELECT>
<script language="JavaScript">
var arrValInterests = new Array();
var arrTextInterests = new Array();
arrValInterests[0] = new Array("0","0");
arrTextInterests[0] = new Array("0","--All Categories--");
arrValInterests[1] = new
Array("3","0","752","...removed...","724","653","654");
arrTextInterests[1] = new Array("3","--All
Categories--","Abyssinia","Afghanistan","...removed...","USA","Venezuela","Vietnam","West
Indies","Yemen","Yugoslavia","Zanzibar");
arrValInterests[2] = new Array("5","0","661","...removed...","662");
arrTextInterests[2] = new Array("5","--All Categories--","British
Coins-All","...removed...","Sylloge of Coins of the British Isles");
arrValInterests[3] = new Array("1","...removed...","36");
arrTextInterests[3] = new Array("1","--All
Categories--","...removed...","Treasure","US Coins");
arrValInterests[4] = new Array("4","0","121","...removed...","384");
arrTextInterests[4] = new Array("4","--All Categories--","British
orders","...removed...","Single Campaign Medals");
arrValInterests[5] = new Array("6","0");
arrTextInterests[5] = new Array("6","--All Categories--");
</script>
<script language="JavaScript">
function selectInterests(frm)
{
// Obtain the first dimension position of the currently selected
var i = frm.adv_category.selectedIndex;
var n = frm.adv_interests.selectedIndex;
if (i > 0){
// Inititalise the new adv_interests selection
frm.adv_interests.options.length = arrValInterests.length - 1;
// Now select the the items associated with the selected option
for (var j=1; j < arrValInterests.length; j++){
frm.adv_interests.options[j-1].text = arrTextInterests[j];
frm.adv_interests.options[j-1].value = arrValInterests[j];
}
frm.adv_interests.options[0].selected = true;
}
else
{
// User has reselected the blank 'adv_interests' option
frm.adv_interests.options.length = 1;
frm.adv_interests.options[0].text ="--Please Select-- ";
frm.adv_interests.options[0].value = "";
}
} </script>