# Java script problem in IE

**URL:** <https://www.ruby-forum.com/t/java-script-problem-in-ie/180029>\
**Category:** Rails\
**Created:** [December 10, 2009, 12:30am UTC](https://www.ruby-forum.com/t/java-script-problem-in-ie/180029 "2009-12-10T00:30:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayur\_sk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@mayur\_sk](https://www.ruby-forum.com/u/mayur_sk)\
**Post date:** [December 10, 2009, 12:30am UTC](https://www.ruby-forum.com/t/java-script-problem-in-ie/180029/1 "2009-12-10T00:30:56Z")

</div>

i have a drop down and i populate it by java script and it looks like  
this as below . the problem is in line “dd.add(new  
Option(arr[i],arr[i]), null);” the error in IE is type mismatch. in  
Mozilla it works fine …

java script  
function toggle\_category2\_drop\_down(type, sel,typ,fin)  
{

if(type == ‘FastenerItem’)  
{  
var opt =  
$(‘inventory\_item\_category\_drop\_down’).options[$(‘inventory\_item\_category\_drop\_down’).selectedIndex].text;  
var arr = [];  
switch (opt)  
{  
case ‘Binding’:  
arr = [‘Comb’, ‘Coil’, ‘Twin Loop’, ‘Spiral-O’, ‘Velo’, ‘Wire’,  
‘Thermal’, ‘Zip’, ‘Tape’, ‘Ring’, ‘Screw Post’, ‘Prong’, ‘Clasp’,  
‘Tie’,‘Staple’];  
arr.sort();  
break  
case ‘Reinforcing’:  
arr = [‘Eyelet’, ‘Grommet’,‘Tape’];  
arr.sort();  
break  
}

```
 if($('inventory_item_type_drop_down') != null)
{
  var dd = $('inventory_item_type_drop_down');
  dd.options.length = 0;
  for(var i=0;i<arr.length;i++)
  {
     dd.add(new Option(arr[i],arr[i]), null);
  }
  if(sel == '' || arr.indexOf(sel) == -1)
    {dd.selectedIndex = 0;}
  else
    {dd.selectedIndex = arr.indexOf(sel);}
}

```

}
