script fungerer ikke i netscape + firefox
Jeg har et script som kun virker i IE, men ikke i netscape, og ville gerne have det til at virke begge steder:Jeg har 3 dropdown boxe på min side. Den første er fyldt når siden loades, når 2 fyldes med værdier afhængig af valg i nummer 1 etc.
Den første box bliver fyldt ok, men når man har valgt en værdi i box no. 1 kommer der ingen værdier i box no. 2... Kan nogen løse dette???
koden er her:
//put items into the arrays...
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();
var arrItemsLocID1 = new Array();
arrItemsLocID1[0] = "1";
arrItems1[0] = "36";
arrItemsGrp1[0] = "2";
arrItemsLocID1[1] = "15";
arrItems1[1] = "225";
arrItemsGrp1[1] = "16";
arrItemsLocID1[2] = "15";
arrItems1[2] = "325";
arrItemsGrp1[2] = "24";
arrItemsLocID1[3] = "15";
arrItems1[3] = "318";
arrItemsGrp1[3] = "22";
arrItemsLocID1[4] = "15";
arrItems1[4] = "41";
arrItemsGrp1[4] = "27";
arrItemsLocID1[5] = "15";
arrItems1[5] = "118";
arrItemsGrp1[5] = "29";
var arrItems2 = new Array();
var arrItemsGrp2 = new Array();
var arrItemsLocID2 = new Array();
arrItemsLocID2[0] = "2";
arrItems2[0] = "1";
arrItemsGrp2[0] = "3";
arrItemsLocID2[1] = "2";
arrItems2[1] = "2";
arrItemsGrp2[1] = "4";
arrItemsLocID2[2] = "2";
arrItems2[2] = "3";
arrItemsGrp2[2] = "5";
arrItemsLocID2[3] = "2";
arrItems2[3] = "4";
arrItemsGrp2[3] = "6";
arrItemsLocID2[4] = "2";
arrItems2[4] = "5";
arrItemsGrp2[4] = "7";
arrItemsLocID2[5] = "2";
arrItems2[5] = "6";
arrItemsGrp2[5] = "8";
arrItemsLocID2[6] = "2";
arrItems2[6] = "7";
arrItemsGrp2[6] = "9";
arrItemsLocID2[7] = "2";
arrItems2[7] = "8";
arrItemsGrp2[7] = "10";
arrItemsLocID2[8] = "2";
arrItems2[8] = "12";
arrItemsGrp2[8] = "11";
arrItemsLocID2[9] = "2";
arrItems2[9] = "13";
arrItemsGrp2[9] = "12";
arrItemsLocID2[10] = "2";
arrItems2[10] = "K";
arrItemsGrp2[10] = "13";
arrItemsLocID2[11] = "2";
arrItems2[11] = "9";
arrItemsGrp2[11] = "14";
arrItemsLocID2[12] = "16";
arrItems2[12] = "1 syre";
arrItemsGrp2[12] = "17";
arrItemsLocID2[13] = "16";
arrItems2[13] = "1";
arrItemsGrp2[13] = "18";
arrItemsLocID2[14] = "16";
arrItems2[14] = "2";
arrItemsGrp2[14] = "19";
arrItemsLocID2[15] = "16";
arrItems2[15] = "K";
arrItemsGrp2[15] = "20";
arrItemsLocID2[16] = "22";
arrItems2[16] = "Dummy";
arrItemsGrp2[16] = "23";
arrItemsLocID2[17] = "24";
arrItems2[17] = "k";
arrItemsGrp2[17] = "25";
arrItemsLocID2[18] = "22";
arrItems2[18] = "k";
arrItemsGrp2[18] = "26";
arrItemsLocID2[19] = "27";
arrItems2[19] = "dummy";
arrItemsGrp2[19] = "28";
arrItemsLocID2[20] = "29";
arrItems2[20] = "dummy";
arrItemsGrp2[20] = "30";
function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
// Empty the third drop down box of any choices
for (var q=locationChoices.thirdChoice.options.length;q>=0;q--) locationChoices.thirdChoice.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "[SELECT]" ;
controlToPopulate.add(myEle);
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if(control.name == "firstChoice")
{
if ( arrItemsLocID1[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = GroupArray[x];
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
if(control.name == "secondChoice")
{
if ( arrItemsLocID2[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = GroupArray[x];
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
}
------------------------------------------------------------
her er de 3 select boxe som er på html siden...
<select id="firstChoice" name="firstChoice" tabindex="2" onchange="selectChange(this, locationChoices.secondChoice, arrItems1, arrItemsGrp1);">
<option value="X" selected>[SELECT]</option>
<option value="1">11</option>
<option value="15">30</option>
</select>
<select id="secondChoice" name="secondChoice" tabindex="3" onchange="selectChange(this, locationChoices.thirdChoice, arrItems2, arrItemsGrp2);">
<option>[SELECT]</option>
</select>
<select id="thirdChoice" name="thirdChoice" tabindex="4" ></select>
