title: Passing field values into variable and hidden input with Javascript elegantly
body: <p>I would like to verify information submitted with a <code>document.write</code> and pass the form values into hidden form fields (if it's necessary) for final submittal.  Using an online script I have the field value contained as such</p>
  
  <pre><code>if (splitArray[i] == 'textname')    
  document.formname.textname.value = unescape(splitArray[i+1]);
  </code></pre>
  
  <p>What's the cleanest way to both print the value on the page in somewhat of a sentence structure, and also ready the values for submittal?</p>
  
  <pre><code>...
  if (splitArray[i] == 'textname')  
  var x = unescape(splitArray[i+1]);
  }
  
  function writeIt(y) { document.write(y); }
  </code></pre>
  
  <p>to print on page confirm.html: </p>
  
  <pre><code>Hello &lt;script&gt;writeIt(x);&lt;/script&gt;, welcome to Wonderland.
  </code></pre>
  
  <p>to pass on page confirm.html: </p>
  
  <pre><code>&lt;input type="hidden" name="textname" value="&lt;script&gt;writeIt(x);&lt;/script&gt;"&gt;
  ...
  &lt;input type="submit" value="Submit"&gt;&lt;/form&gt;
  </code></pre>
  
  <p>Is passing the values into <code>&lt;input&gt;</code> fields necessary, or can I rely on <code>document.formname.textname.value</code> to contain the form values (without actually having to write out the HTML (form <code>&lt;input&gt;</code>) other than the submit button?</p>