views:

89

answers:

2

I have a html form that posts to a new page on submit. If required a user can click a button to make a small table visible in a div box. 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 .

the div box code

      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

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

Any help or thoughts would be much appreciated

thanks Mick

A: 

Adding form elements via innerHTML is (unfortunately) unreliable, particularly in 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.

The visibility of the form fields (e.g., whether they're inside a hidden div) shouldn't make any difference to their being submitted with the form. Of course, disabled form fields aren't submitted, but I don't get the impression you're disabling them.

T.J. Crowder
+2  A: 

I'd have to guess the form doesn't included the "quote" element, but what would really be helpful is a more complete snippet of HTML.

Bialecki
Thanks for the comments . I had the <div id= 'quote'></div> before the form tag. as soon as I placed it after the form it worked a treat !thanks all for your help
Mick