다음 코드가 있습니다. 코드는 완료된 선택을 기반으로하는 목록 상자를 채 웁니다. IE6에서 해고 함수는하지만 내 코드는 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에서 작동, 전체 테스트 케이스하시기 바랍니다. 그러나'options.add'는 IE 외부에서 작동하지 않는 비표준 메소드입니다 (예를 들어'options [options.length] = opt' 대신에 사용하십시오). 글로벌'event'는 IE 전용입니다. 어쨌든 추천할만한 것은 아닙니다). – bobince