0

I am trying to use javascript on the form's load to pre-select some options. This is what I have.

    var mar=document.getElementById('region');
    var marketarray = '@marketlistdb@'.split("|");
    for( var l = 0; l < mar.options.length; l++ )
    {
        var o = mar.options[l];
        if ( marketarray.indexOf( o.text ) != -1 )
        {
            mar.selected = true;
        }
    }

But this will not select the elements in the select tag. I saw this solution elsewhere (Javascript to Select Multiple options) I tried this solution, but it will not work for whatever reason. Does anyone see anything wrong that would cause this not to select?

We have placed alerts within the for loop and within the if statement to verify that we have true matches between the array and each individual option.

Community
  • 1
  • 1
1337Atreyu
  • 223
  • 2
  • 5
  • 12

0 Answers0