<script language=javascript>
<!--
function show()
{
var op=document.myform;
op.e.value="0";
for(var i=0;i<4;i++)
if(op.a[i].checked)
op.e.value=parseFloat(op.e.value)+parseFloat(op.a[i].value);
}
//-->
</script><form name="myform" action="" method="post">
<input type=checkbox name="a" value="11" onclick="show()">a<br>
<input type=checkbox name="a" value="22" onclick="show()">b<br>
<input type=checkbox name="a" value="33" onclick="show()">c<br>
<input type=checkbox name="a" value="44" onclick="show()">d<br><br>
<input type=text name="e" value="" size=20>
</form>

解决方案 »

  1.   

    <input name=a size=10>+
    <input name=b size=10>+
    <input name=c size=10>+
    <input name=d size=10>
    <input type=submit value="=" onclick="gettheresult()">
    <input name=e><br><script language=javascript>function gettheresult()
    {
    var theresult=a.value*1+b.value*1+c.value*1+d.value*1
    e.value=roundFun(theresult,1);
    }
    function roundFun(numberRound,roundDigit) //四舍五入,保留位数为roundDigit ,供计算时用 {
    with(Math){
    return round(numberRound*pow(10,roundDigit))/pow(10,roundDigit);
    }
    }</script>