title: How to generate a random invoice number
body: <p>How do I get the random invoice number to display in the form? </p>
  
  <p>I have built a WordPress site that will have a donation form. I do not want the user to be able to edit the code so I have added being added to the site via a shortcode. Since it is included as a short code I have to escape <code>"</code>. Could that be the reason the random number is not replacing the value of <strong>UMinvoice</strong>?</p>
  
  <p>I notice that the value for UMinvoice returns as <code>value=</code> in the source code unless I add a blank space <code>value=\" \"</code></p>
  
  <p><strong>EDIT</strong>: I have removed this from the short code and placed it in a custom template. All slashes have been removed. I am now getting 'undefined' is not an object (evaluating 'document.getElementsByName("UMinvoice")[0].value = random_num')</p>
  
  <p>The script I have creating a random invoice number is</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
  var d = new Date();
  function f(n) { return n &lt; 10 ? '0' + n : n; }  
  var random_num = Math.floor(Math.random() * (99999999999 -  10000000000)) + 10000000000;
  random_num = d.getFullYear() + f(d.getMonth()+1) + f(d.getDate()) + random_num; 
  document.getElementById("invoice")[0].value = random_num;
  &lt;/script&gt;
  </code></pre>
  
  <p>The form I am using is (<em>the portion with the invoice input</em>)</p>
  
  <pre><code>&lt;form id="donation" action="https://secureurl" method="POST"&gt;
  &lt;input type="hidden" name="UMkey" value="key" /&gt;
  &lt;input type="hidden" name="UMcustreceipt" value="yes" /&gt;
  &lt;input type="hidden" name="UMinvoice" id="invoice" value=""&gt;
  </code></pre>