hello i have a probleme with a javascript that work on IE, safari,Chrome but doesn't in firefox or opera :
it is a simple script that erase and rewrite the content of 2 select list/menu from an 2 array.. I will apreciate some help on this one, here is the code that write the option of the select menu:
i will put all the script and highlight where is the problem:
<script language="javascript">//(arrays are empty for space)
var sub_cat_array = new Array(); //1st array for 2nd list
var sub_cat_array2 = new Array(); //2nd array for 3rd list
window.onload=function(){
document.getElementById("hidden_elements").style.display="none";
document.getElementById("hidden_elements2").style.display="none";
document.getElementById("markedslist").onchange=selcted;
document.getElementById("subcat1").onchange=selcted2;
}
function selcted(){
document.getElementById("hidden_elements").style.display="none";//reset
document.getElementById("hidden_elements2").style.display="none";//reset
if(document.getElementById("markedslist").value !="all"){
document.getElementById("hidden_elements").style.display="block";
}else{
document.getElementById("hidden_elements").style.display="none";
document.getElementById("hidden_elements2").style.display="none";
}
var markedslist=this.value;
var sub_cat=document.getElementById("subcat1");
sub_cat.options.length=0;
//probleme start here
for(var i=0;i< sub_cat_array.length; i++){
var st = sub_cat_array[0];
if(st==markedslist){
var opt = new Option(sub_cat_array[1]);
// var val = sub_cat_array[2];
opt.value=sub_cat_array[2];
try{
sub_cat.add(opt,opt.value);
}catch(e){
sub_cat.add(opt);
}
}
}
} // probleme finish here and it is the same for the function selcted2 below
function selcted2(){
if(document.getElementById("subcat1").value != "all"){
document.getElementById("hidden_elements2").style.display="block";
}else{ document.getElementById("hidden_elements2").style.display="none";
}
var subcat1=this.value;
var sub_cat2=document.getElementById("subcat2");
sub_cat2.options.length=0;
for(var i=0;i< sub_cat_array2.length; i++){
var st2 = sub_cat_array2[0];
if(st2==subcat1){
var opt2 = new Option(sub_cat_array2[1]);
//var val2 = sub_cat_array2[2];
opt2.value=sub_cat_array2[2];
try{
sub_cat2.add(opt2,opt2.value);
}catch(e){
sub_cat2.add(opt2);
}
}
}
}
</script>
it is a simple script that erase and rewrite the content of 2 select list/menu from an 2 array.. I will apreciate some help on this one, here is the code that write the option of the select menu:
i will put all the script and highlight where is the problem:
<script language="javascript">//(arrays are empty for space)
var sub_cat_array = new Array(); //1st array for 2nd list
var sub_cat_array2 = new Array(); //2nd array for 3rd list
window.onload=function(){
document.getElementById("hidden_elements").style.display="none";
document.getElementById("hidden_elements2").style.display="none";
document.getElementById("markedslist").onchange=selcted;
document.getElementById("subcat1").onchange=selcted2;
}
function selcted(){
document.getElementById("hidden_elements").style.display="none";//reset
document.getElementById("hidden_elements2").style.display="none";//reset
if(document.getElementById("markedslist").value !="all"){
document.getElementById("hidden_elements").style.display="block";
}else{
document.getElementById("hidden_elements").style.display="none";
document.getElementById("hidden_elements2").style.display="none";
}
var markedslist=this.value;
var sub_cat=document.getElementById("subcat1");
sub_cat.options.length=0;
//probleme start here
for(var i=0;i< sub_cat_array.length; i++){
var st = sub_cat_array[0];
if(st==markedslist){
var opt = new Option(sub_cat_array[1]);
// var val = sub_cat_array[2];
opt.value=sub_cat_array[2];
try{
sub_cat.add(opt,opt.value);
}catch(e){
sub_cat.add(opt);
}
}
}
} // probleme finish here and it is the same for the function selcted2 below
function selcted2(){
if(document.getElementById("subcat1").value != "all"){
document.getElementById("hidden_elements2").style.display="block";
}else{ document.getElementById("hidden_elements2").style.display="none";
}
var subcat1=this.value;
var sub_cat2=document.getElementById("subcat2");
sub_cat2.options.length=0;
for(var i=0;i< sub_cat_array2.length; i++){
var st2 = sub_cat_array2[0];
if(st2==subcat1){
var opt2 = new Option(sub_cat_array2[1]);
//var val2 = sub_cat_array2[2];
opt2.value=sub_cat_array2[2];
try{
sub_cat2.add(opt2,opt2.value);
}catch(e){
sub_cat2.add(opt2);
}
}
}
}
</script>