JavaScript在IE中工作但在Firefox中不工作

时间:2012-04-24 14:30:27

标签: javascript

function onLoadMoneyEarned(size){
    for(var i=1;i<=size;i++){
        var countStr1 = 'howOften__JB1_'+i;
        var countStr2 = 'howOften__JB2_'+i;
        var countStr3 = 'howOften__JB3_'+i;
        var countStr4 = 'howOften__JB4_'+i;

        var hrsPerWeek1 = 'hrsPerWeek__JB1_'+i
        var hrsPerWeek2 = 'hrsPerWeek__JB2_'+i
        var hrsPerWeek3 = 'hrsPerWeek__JB3_'+i
        var hrsPerWeek4 = 'hrsPerWeek__JB4_'+i

        var dropDownValue1 = document.getElementById(countStr1).value;
        var dropDownValue2 = document.getElementById(countStr2).value;
        var dropDownValue3 = document.getElementById(countStr3).value;
        var dropDownValue4 = document.getElementById(countStr4).value;

        var textbox1 = document.getElementById(hrsPerWeek1);
        textbox1.disabled = true;
        var textbox2 = document.getElementById(hrsPerWeek2);
        textbox2.disabled = true;
        var textbox3 = document.getElementById(hrsPerWeek3);
        textbox3.disabled = true;
        var textbox4 = document.getElementById(hrsPerWeek4);
        textbox4.disabled = true;

        if(dropDownValue1=="HR"){
            textbox1.disabled = false;
        }
        if(dropDownValue2=="HR"){
            textbox2.disabled = false;
        }
        if(dropDownValue3=="HR"){
            textbox3.disabled = false;
        }
        if(dropDownValue4=="HR"){
            textbox4.disabled = false;
        }
    }

这是在IE中工作的那个..

我正在调用这样的脚本

<script  language="javascript" type="text/javascript">
$(window).load(function(){onLoadMoneyEarned("<%=nameLength%>");});
</script>

此脚本的主要功能是,只有在我们旁边的下拉列表中选择每小时时才启用小时文本字段。但是它在Firefox中抛出验证错误

任何帮助表示赞赏

1 个答案:

答案 0 :(得分:0)

结尾的花括号似乎不见了。尝试在函数onLoadMoneyEarned。

的最后添加一个结束}