javascript
2011-05-25 47 views 0 likes 
0

我有一个订单表单脚本,其中有一个函数说明如果作业将花费比x更长的时间刷新消息。脚本工作正常,如果我离开我的if语句,但如果我把它放在它只执行,如果X变量符合if条件,这是否有意义?做如果语句执行后停止代码?

我的脚本...

if (EstimatedCoreHours >= 50000) 
    { 
    document.getElementById("AccountManagement").innerHTML='You have a big Job on your hands - Contact Us!'; 
    document.getElementById("AccountManagement").style.backgroundColor="yellow"; 
    } 
    else 
    { 
    document.getElementById("AccountManagement").innerHTML=''; 
    document.getElementById("ContBtn").style.display=""; 
    } 

    if (EstimatedCoreHours >= 100000) 
    { 
    document.getElementById("LeadTimes").innerHTML='5 Business Days!'; 
    document.getElementById("LeadTimes").style.backgroundColor="yellow"; 
    } 
    else if (EstimatedCoreHours >=25000) 
    { 
    document.getElementById("LeadTimes").innerHTML='2 Days'; 
    document.getElementById("LeadTimes").style.backgroundColor="yellow"; 
    } 
    else 
    { 
    document.getElementById("LeadTimes").innerHTML='Right Away'; 
    document.getElementById("LeadTimes").style.backgroundColor="yellow"; 
    } 
+0

请重新说明... – Eineki 2011-05-25 09:44:23

回答

0

如果语句将不会停止执行。解释器在代码中遇到错误时执行停止。检查内部使用的变量是否定义了

0

你在这里混合了ifs和else-ifs,并且缩进是错误的。如果EstimatedCoreHours是150,000,那么前两个if都会触发。你是不是指他们要嵌套?

最后一点,标准运行50,000,100,000,25,000。您是否故意测试这些值,或者是否存在拼写错误?

相关问题