日期:2014-05-16  浏览次数:20467 次

怎么来判断?
<form       name=hrong>
    <select   name= "yyy "   >
        <option   selected   > 正常 </option>
        <option> 反常 </option>
    </select>
    </font>
<input       name=txt1   onkeydown= "if(event.keyCode==13)event.keyCode=9 "> <br>      
    <input       name=txt2   onkeydown= "if(event.keyCode==13)event.keyCode=9 "> <br>      
    <input       name=txt3     onkeydown= "if(event.keyCode==13)event.keyCode=9 "   onfocus= "mm() "> <br>      
    </form>      
       
    <SCRIPT       LANGUAGE= "JavaScript "> <!--      
    function       mm()      
    {      
            with(document.hrong)      
            {      
                    if(!txt1.value       ||       !txt2.value){alert( '有一项为空,       不予计算! ');       return;}      
                    var       n1       =       parseInt(txt1.value)?       parseInt(txt1.value)       :       0;      
                    var       n2       =       parseInt(txt2.value)?       parseInt(txt2.value)       :       0;      
                    txt3.value       =       n1       +       n2;      
            }      
    }      
    //--> </SCRIPT>

在选择反常时txt3里的结果必须为0。

------解决方案--------------------
<script language= "JavaScript "> <!--
function mm()
{
with(document.hrong)
{
if (yyy.options[yyy.selectedIndex].text == '正常 ') {
if (!txt1.value || !txt2.value){
alert( '有一项为空, 不予计算! ');
return;
}
var n1 = parseInt(txt1.value)? parseInt(txt1.value) : 0;
var n2 = parseInt(txt2.value)? parseInt(txt2.value) : 0;
txt3.value = n1 + n2;
}
else if (yyy.options[yyy.selectedIndex].text == '反常 ') {
txt3.value = 0;
}
}
}
//--> </script>
------解决方案--------------------
呵呵,不好意思
没测试正常情况
<html>
<head>

</head>

<body >
<form name=hrong>
<select name= &qu