gpt4 book ai didi

javascript - IE 6 中的单击问题

转载 作者:行者123 更新时间:2023-11-28 02:58:08 25 4
gpt4 key购买 nike

我有以下代码。该代码根据完成的选择填充列表框。但我的代码在 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);
}
}
}
}

}

}

最佳答案

该函数在 IE6 下触发吗?因为一个常见的问题是将函数附加到onclick事件上(在IE6下有问题)。

改用onchange

关于javascript - IE 6 中的单击问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2048859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com