请大家帮帮忙!

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
     </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function validate(){
       var firstPriceList = document.getElementsByName("firstPrice");
       var secondPriceList = document.getElementsByName("secondPrice");
           var firstPrice = 0;
       var secondPrice = 0;
            for (var i = 0; i < firstPriceList.length; i++) {
                if(firstPriceList[i].checked==true){
                     firstPrice+=parseInt(firstPriceList[i].value);
    }
            }
    for (var i = 0; i < secondPriceList.length; i++) {
                if(secondPriceList[i].checked==true){
                     secondPrice+=parseInt(secondPriceList[i].value);
    }
            }
    if(firstPrice>secondPrice){
    alert("我比你大!");
    }else{
    alert("我不如你大!");
    }
    }
    //-->
    </SCRIPT>
     <BODY>
     <table>
     <tr>
     <td>  <input type="checkbox" name="firstPrice" checked value="4569"/>
       <input type="checkbox" name="firstPrice" checked value="1111"/>
        <input type="checkbox" name="firstPrice"/>
     <input type="checkbox" name="firstPrice" checked value="3456"/>
      <input type="checkbox" name="firstPrice" checked value="1234"/>
       <input type="checkbox" name="firstPrice"/>
        <input type="checkbox" name="firstPrice" checked value="4589"/>
     <input type="checkbox" name="firstPrice"/> </td>
     </tr>
     <tr>
     <td>
       <input type="checkbox" name="secondPrice" checked value="4569"/>
       <input type="checkbox" name="secondPrice"/>
        <input type="checkbox" name="secondPrice" checked value="3333"/>
     <input type="checkbox" name="secondPrice" value="3456"/>
      <input type="checkbox" name="secondPrice" checked value="1234"/>
       <input type="checkbox" name="secondPrice"/>
        <input type="checkbox" name="secondPrice" checked value="4589"/>
     <input type="checkbox" name="secondPrice"/>
     </td>
     </tr>
     <tr>
     <td>
       <input type="button" value=" + " onClick="validate();"/>
     </td>
     </tr>
     </table> </BODY>
    </HTML>
    这种方法是通用的 
    你可以用别的方法
    例如比较两个复选被选中的个数大小来比较 前提是:你说的4位整数是非负的
    利用这种相加的方法是通用的
      

  2.   

    unction validate(){
      var firstPriceList = document.getElementsByName("firstPrice");
      var secondPriceList = document.getElementsByName("secondPrice");
          var firstPrice = 0;
      var secondPrice = 0;
            for (var i = 0; i < firstPriceList.length; i++) {
                if(firstPriceList[i].checked==true){
                    firstPrice+=parseInt(firstPriceList[i].value);
    }
            }
    for (var i = 0; i < secondPriceList.length; i++) {
                if(secondPriceList[i].checked==true){
                    secondPrice+=parseInt(secondPriceList[i].value);
    }
            }
    if(firstPrice>secondPrice){
    alert("我比你大!");
    }else{
    alert("我不如你大!");
    }
    }
    //-->
    </SCRIPT> 可以啊!