Одиночный клик в IE 6 - PullRequest
       5

Одиночный клик в IE 6

1 голос
/ 12 января 2010

У меня есть следующий код. Код заполняет список на основе сделанного выбора. Но мой код работает в IE 7 и не работает в IE 6.

//----------------------------------------------------------------------------------------------
//fill the location list on the basis of Country

function FillLocationList()
{
    var opt =  document.createElement("OPTION");
    var selected =document.getElementById('drpCountryName').selectedIndex;
    var size = document.getElementById('drpCountryName').options.length;
     if(!event.ctrlKey && !event.shiftKey)
     {

        document.getElementById('drpLocation').options.length = 0;
        for(var i=0;i<locationArray.value.length;i++)
        {

            //if(document.getElementById('drpLocationReportsTo').value == locationArray.value[i].LocationRptId)
            if(document.getElementById('drpCountryName').value == locationArray.value[i].CountryCode)
            {
                 opt =  document.createElement("OPTION");
                 opt.text = locationArray.value[i].LocationName;
                 opt.value=locationArray.value[i].LocationId;
                 document.getElementById("drpLocation").options.add(opt);
            }
        }

     }


    else if(event.ctrlKey || event.shiftKey)
    {

        document.getElementById('drpLocation').length = 0;
        for(j=0;j<document.getElementById('drpCountryName').length;j++)
        {
           var currentLocation = document.getElementById('drpCountryName').options[j].value;
            if(document.getElementById('drpCountryName').options[j].selected)
            {   
                for(var i=0;i<locationArray.value.length;i++)
                {

                    if(currentLocation == locationArray.value[i].CountryCode)
                    {
                         opt =  document.createElement("OPTION");
                         opt.text = locationArray.value[i].LocationName;
                         opt.value=locationArray.value[i].LocationId;
                         document.getElementById("drpLocation").options.add(opt);
                    }
                }
            }
       }

    }

}

Ответы [ 2 ]

1 голос
/ 12 января 2010

Функция запускается под IE6? Потому что распространенной проблемой является присоединение функции к событию onclick (которое имеет проблемы с IE6).

Используйте onchange вместо.

0 голосов
/ 12 января 2010

Если вы запускаете его с помощью onclick в IE6, попробуйте это, хорошо, если вы еще этого не делаете. IE6 имеет некоторые проблемы с использованием функций JavaScript в событии onclick.

onclick = "FillLocationList (); event.returnValue = false; вернуть false;"

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...