title: How to enter variable content into form field
body: <p>I am attempting to place the selected image file number (from a slideshow) into a form field with the onClick trigger but I get the console message Uncaught TypeError: Property 'value' of object # is not a function.</p>
  
  <p>My function is;</p>
  
  <pre><code>function ifExistsWrite(str) {
      var re = new RegExp('\"', 'gi');
      var newstr = str.replace(re, '&amp;quot;');
      if (newstr != "")
          document.write(newstr + "&lt;br&gt;");
  }
  
  function fileNumber() {
      document.getElementById(id = "item_number").value(ifExistsWrite("%CAPTIONTITLE%"));
  }
  </code></pre>
  
  <p>And I am calling the value like this;</p>
  
  <p><code>&lt;form&gt;
            &lt;input type="hidden" id="item_number" name="%CAPTIONTITLE%" value=""&gt;
            &lt;button type="submit" onclick="fileNumber();"&gt;Large&lt;/button&gt;
   &lt;/form&gt;</code></p>
  
  <p>I must confess that my 14 yr old son is better at javascript than me but he can't see the problem either.</p>