我在表单中有一个隐藏字段,其值由 javascript 设置。我已经确认该值确实已设置。但是,当我尝试将其发送到 servlet 时,它会产生一个空值。我确实使用 POST 方法和“提交”按钮提交给 servlet。该值是通过用户在“qtyText”文本框中输入获得的。在 JS 中,它的值是动态设置的。为什么它不会被发送到 servlet?JS
   function(calculateTotalPrice(txtbxvalue, price)
  {
   myForm = document.forms[0];        
      var txtBx = myForm.elements['qtyText'];
      var txtBxHidden = myForm.elements['qtyTextHidden'];
      for(var i = 0; i < txtBx.length; i++) 
         {
          var curTxtBx = txtBx[i].value; 
          var txtBxHiddenBx = txtBxHidden[i];
           txtBxHiddenBx.value = curTxtBx;
         }
   }
HTML
<table>
   <c:forEach items="${ListInServlet}" var= "exBean">
  <form name = "tableForm" method = "post" action= "/rpsapp/someservlet">
    <input type="hidden" name="productId" value= "<c:out Value 
                                          = "${exBean.productId}"/>"  />
         <input type="hidden"  value = "somevalue" name="qtyTextHidden"/>
         <input name = "qtyText" type = "textbox" size = "2" value = "" onChange 
                              = "calculateTotalPrice(this, '${exBean.price}')"/>
   </c:forEach>
  </form>
</table>