Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First time...works in IE, but not Moz

Status
Not open for further replies.

mattquantic

Programmer
Joined
Mar 28, 2004
Messages
196
Location
GB
Hi. I am dynamically populating a dropdown. But for some reason it works in Moz but not IE???

The code is simple and i just don't see whats not right...

Code:
<script type="text/javascript" language="JavaScript">
   function populateDrop(){
      for(var i = 1;i <= jsaysType1_1.length; i++){
         var newoption = new Option(jsaysType1_1[i].thename,jsaysType1_1[i].value);
         
//this for ie (dynamically left out by server if not ie)
document.AddEditProducts.Type1_1.add(newoption);

//this for moz(dynamically left out by server if not moz)
document.AddEditProducts.Type1_1.add(newoption,null);
           
         if(jsaysType1_1[i].selected == 1){
            document.AddEditProducts.Type1_1[i].selected = true;
            document.AddEditProducts.Type1_1[i].style.color = "#ffffff";
            document.AddEditProducts.Type1_1[i].style.backgroundColor = "#005F8C";                              
         }
         else{
            document.AddEditProducts.Type1_1[i].selected = false;
         }
      }  
   }                  
</script>
                  
<form name="AddEditProducts" method="post" action="/admin/addedit_product.cfm" enctype="multipart/form-data">                  
   <select name="Type1_1" class="form_input">
      <option value="" style="background-color:#C0D9E4;color:#373666;">Type</option>                  
                                          
         <script type="text/javascript" language="JavaScript">
            jsaysType1_1 = new Array();
            jsaysType1_1[1] = new Object();
            jsaysType1_1[1].thename = 'angels';
            jsaysType1_1[1].value = '20';                           
         </script>                       
      
   </select>  

   <script type="text/javascript" language="JavaScript">
      populateDrop('jsaysType1_1','Type1_1','AddEditProducts');
   </script> 
</form>

Weird??

M@)
 
I mean works in Moz but NOT IE...
 
what exactly is it you're trying to do here? this is poorly-formed code - at all costs, javascript should be separated from your html.

there is likely an easy solution, just let me know what you're trying to accomplish.

*cLFlaVA
----------------------------
[tt]0101 is binary code for "supreme programmer of omnipotent power"[/tt] - adam0101
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Hi. I have just managed to separate it from the JS:

Code:
<form name="hello" method="post" action="/admin/addedit_product.cfm" enctype="multipart/form-data"> 
   <select name="temp1">
   </select>
</form> 

<script type="text/javascript" language="JavaScript">
   var selecvals = new Array();
   selecvals[1] = new Object();   
   selecvals[1].name = "working";
   selecvals[1].value = "working";   

   function saysomething(t1, t2, t3) {
     alert("t1="+t1+" and t2="+t2+" and t3="+t3);
     thearray = eval(t1);
     for(var i = 1;i < thearray.length; i++){
        var newoption = new Option(thearray[i].name,thearray[i].value);
        document[t2][t3].add(newoption);
     }
     
   }
   jcalls = new Array();
   var temp = new Object();
   temp.functionname = "saysomething";
   temp.functionatts = new Array(); 
   temp.functionatts[0] = "selecvals";//values array
   temp.functionatts[1] = "hello";//form name
   temp.functionatts[2] = "temp1";//form element   
   
   jcalls.push(temp);
   
   for(var i=0;i<=jcalls.length;i++){
      window[jcalls[i].functionname].apply(null,jcalls[i].functionatts);
   }   

</script>

Thanks to tek-tips this is working great...

M@)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top