同意patchclass(黑翼),做一个Form,将table放里面,希望读取的数据用<input >字段,提交到自己的servlet,用request读取就可以了

解决方案 »

  1.   

    <table>
     <tr>
       <td>名称</td>
       <td>票价</td>
       <td>数量</td>
       <td>合计</td>
     </tr>
     <tr>
       <td>前门</td>
       <td><input type=text name=pricefront value=10>¥</td>
       <td><input type=text name=front></td>
       <td><input type=text name=sumfront></td>
     </tr>
     <tr>
       <td>后门</td>
       <td><input type=text name=priceback value=12>¥</td>
       <td><input type=text name=back></td>
       <td><input type=text name=sumback></td>
     </tr>
    </table>
    <input type=button name=btSum value="计算" onclick=pjsfSum()><script>
     function pjsfSum(){
      var sumfront;
      var sumback;
     
      sumfront = document.all.front.value * document.all.pricefront.value;
      sumback  = document.all.back.value * document.all.priceback.value;}
    </script>
      

  2.   

    窗口的名字: t1
    <form action="" name="t1" method="post"><input name="allv" type="hidden" id="allv" value="0">页面中放两个隐含input<input name="pFront" type="hidden" id="pFront" value="10">
    <input name="pBack" type="hidden" id="pBack" value="20">两个输入框:
    <input name="fCounter" type="text" id="fCounter">
    <input name="bCounter" type="text" id="bCounter"><input type="button" name="count" onClick="javascript:countall();"></form>
    <script>
    //计算值并提交
    function countall(){
      用公式计算出值
      allv = t1.pFront.value * t1.fCounter.value + t1.pBack.value * t1.bCounter.value;
      t1.allv.value = allv;
      t1.action = "<提交到的页面>";
      t1.submit;
    }
    //以上程序没有验证输入的值.
    </script>
      

  3.   

    上面的少了两句,下面的对
    <table>
     <tr>
       <td>名称</td>
       <td>票价</td>
       <td>数量</td>
       <td>合计</td>
     </tr>
     <tr>
       <td>前门</td>
       <td><input type=text name=pricefront value=10>¥</td>
       <td><input type=text name=front></td>
       <td><input type=text name=sumfront></td>
     </tr>
     <tr>
       <td>后门</td>
       <td><input type=text name=priceback value=12>¥</td>
       <td><input type=text name=back></td>
       <td><input type=text name=sumback></td>
     </tr>
    </table>
    <input type=button name=btSum value="计算" onclick="pjsfSum()"><script>
     function pjsfSum(){
      var sumfront;
      var sumback;
     
      sumfront = document.all.front.value * document.all.pricefront.value;
      sumback  = document.all.back.value * document.all.priceback.value;  document.all.sumfront.value = sumfront;
      document.all.sumback.value = sumback;}
    </script>