简体   繁体   English

隐藏的div内的表单发布后没有任何值

[英]Form inside a hidden div has no values on post

I have a html form that posts to a new page on submit. 我有一个html表单,在提交时会发布到新页面。 If required a user can click a button to make a small table visible in a div box. 如果需要,用户可以单击按钮以使一个小表在div框中可见。 this adds more text input fields to my form. 这会将更多的文本输入字段添加到我的表单中。

The problem is, regardless of the div box being hidden or visible none of the additional fields data is sent when the form is posted . 问题是,无论div框处于隐藏状态还是可见状态,发布表单时都不会发送任何其他字段数据。

the div box code div框代码

      function quotevisi()
  {
  document.getElementById("quote").style.visibility = "visible";
  tdat = "" ;
  tdat += "<h2 align='center' >Client Quotation </h2>" ;

  tdat += "<table align='center'cellpadding='1'  width='690px'><tr>"
  tdat += "<td ></td><td>Additional 1</td>" ;
  tdat += "<td ><label><textarea id='line1' cols='50' rows='1'>"
  tdat += "</textarea></label></td></tr>" 

  tdat += "<td ></td><td >Additional 2 </td>" ;
  tdat += "<td ><label><textarea id='line2' name='line2' cols='50' rows='1'>"
  tdat += "</textarea></label></td></tr>"

  tdat += "<td ></td><td >Additional 3 </td>" ;
  tdat += "<td ><label><textarea id='line3' name='line3' cols='50' rows='1'>"
  tdat += "</textarea></label></td></tr>"

  tdat += "<td ></td><td >Special Instructions</td>" ;
  tdat += "<td ><label><textarea id='special' name='special' cols='50' rows='1'>"
  tdat += "</textarea></label></td></tr>"

  tdat += "<td ></td><td ></td> <td>" ;
  tdat += "<input type='button' value='View Quote'          onclick='view_quote()'            />  "

  tdat += "<input type='button' value='Close' onclick='closequote()' />  " 

  tdat += "<td ></td> " ;

  tdat += "</table> "

  // display in the quote div (style sheet) 
  document.getElementById('quote').innerHTML= tdat
  }

The form is a bit big to but the button for the hidden field is this 表单有点大,但是隐藏字段的按钮是这个

<td ><input class="buttn" type="button" value="Extra Quote details "   onclick="quotevisi();" /> </td> 

I would of thought that all this information would go with the form on post . 我认为所有这些信息都将与邮寄表格一起使用。 But it doesent. 但是确实如此。 Oh finally the div box code is placed after this line 哦,最后,将div框代码放在此行之后

<form  style='background-color:ccc' id='form1' name='form1' method='post' action='process.php' > 

Any help or thoughts would be much appreciated 任何帮助或想法将不胜感激

thanks Mick 谢谢米克

我不得不猜测该表单不包含“ quote”元素,但真正有用的是更完整的HTML代码段。

Adding form elements via innerHTML is (unfortunately) unreliable, particularly in IE. 不幸的是,通过innerHTML添加表单元素是不可靠的,尤其是在IE中。 (Table rows and such also have this problem.) This page lists a clever little workaround. (表行等也有此问题。) 此页面列出了一个巧妙的解决方法。 Most JavaScript libraries (like jQuery , Prototype , Closure , ...) will do workarounds for you, FWIW. FWIW大多数JavaScript库(如jQueryPrototypeClosure等)都可以为您解决问题。

The visibility of the form fields (eg, whether they're inside a hidden div) shouldn't make any difference to their being submitted with the form. 表单字段的可见性 (例如,它们是否在隐藏的div内)与通过表单提交它们无关。 Of course, disabled form fields aren't submitted, but I don't get the impression you're disabling them. 当然, 禁用的表单字段不会提交,但我不会给您留下印象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM