为什么我的Javascript不能在IE中运行

时间:2012-04-20 16:40:01

标签: javascript internet-explorer filter

以下是我的代码。它应该过滤一个表。除了IE之外,它在一切功能上都很棒你能帮忙吗?

也许有一个缺少标签或其他东西。我已经多次参与其中,并且真的可以帮助别人的帮助!

<script type="text/javascript">
function hasPath(element, cls) {
    return (' ' + element.getAttribute('pathway')).indexOf(cls) > -1;
}

function hasLevel(element, cls) {
    return (' ' + element.getAttribute('level')).indexOf(cls) > -1;
}

function hasBody(element, cls) {
    return (' ' + element.getAttribute('body')).indexOf(cls) > -1;
}

function QualificationSearch() {
    var imgdiv = document.getElementById("Chosen_Pathway_img");
    var p = document.getElementById("PathwaySelect");
    var pathway = p.options[p.selectedIndex].value;
    if (pathway == "ALLPATHS") {
        pathway = "";
        imgdiv.src = "/templates/superb/images/QualChecker/pic_0.png"
    }
    if (pathway == "ES") {
        imgdiv.src = "/templates/superb/images/QualChecker/pic_1.png"
    }
    if (pathway == "HOUSING") {
        imgdiv.src = "/templates/superb/images/QualChecker/pic_2.png"
    }
    if (pathway == "PLAYWORK") {
        imgdiv.src = "/templates/superb/images/QualChecker/pic_3.png"
    }
    if (pathway == "SC") {
        imgdiv.src = "/templates/superb/images/QualChecker/pic_4.png"
    }
    if (pathway == "YW") {
        imgdiv.src = "/templates/superb/images/QualChecker/pic_5.png"
    }
    var a = document.getElementById("AwardingBodySelect");
    var awardingBody = a.options[a.selectedIndex].value;
    if (awardingBody == "ALLBODIES") {
        awardingBody = "";
    }
    var levelGroup = document.getElementsByName("LevelGroup");
    var chosenLevel = ""
    for (var g = 0; g < levelGroup.length; g++) {
        if (levelGroup[g].checked) {
            chosenLevel += levelGroup[g].value + " ";
        }
    }
    if (chosenLevel == undefined) {
        var chosenLevel = "";
    } else {
        var splitLevel = chosenLevel.split(" ");
        var levelA = splitLevel[0];
        var levelB = splitLevel[1];
        var levelC = splitLevel[2];
        var levelD = splitLevel[3];
        if (levelA == "") {
            levelA = "NOLVL"
        }
        if (levelB == "") {
            levelB = "NOLVL"
        }
        if (levelC == "") {
            levelC = "NOLVL"
        }
        if (levelD == "") {
            levelD = "NOLVL"
        }
    }
    var fil = document.getElementsByName("QList");
    for (var i = 0; i < fil.length; i++) {
        fil.item(i).style.display = "none";
        if ((hasBody(fil.item(i), awardingBody) == true || awardingBody == "") && (hasPath(fil.item(i), pathway) == true || pathway == "") && ((hasLevel(fil.item(i), levelA) == true || hasLevel(fil.item(i), levelB) == true || hasLevel(fil.item(i), levelC) == true || hasLevel(fil.item(i), levelD) == true) || chosenLevel == "")) {
            fil.item(i).style.display = "block";
        }
    }
}
</script>

1 个答案:

答案 0 :(得分:0)

检查分号。 IE比FF更严格。