title: storing ID in hidden field
body: <p>I have a script here right now that will display(alert) me the ID from the reaction and the First Name and Last Name. Now I need it that when I press this button it will store the ID in a hidden form input so it will send it to the database.</p>
  
  <p>Script that alerts the data:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function printIt(id){
  alert(document.getElementById(id).value);
  alert(document.getElementById('naam'+id).value); 
  }
  &lt;/script&gt;
  
  
  &lt;form name="formName"&gt;
  &lt;input type=hidden id="'.$reactie['id'].'" name="abcName" value="'.$reactie['id'] .'"/&gt;
  &lt;input type=hidden id="naam'.$reactie['id'].'" name="abcName" value="Reactie op bericht van '.$reactie['voornaam'].' ' .$reactie['achternaam'] .'"/&gt;
  &lt;input class="btn btn-primary btn-xs" type=button value="Reageer" onclick="printIt(\''.$reactie['id'] .'\')" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Script that sends the form (where the ID needs to be added) to the database:</p>
  
  <pre><code>&lt;?php if(isset($_POST['react_btn'])){ unset($q1); $q1['reactie'] = $app-&gt;check_string($_POST['reactie']); 
  $q1['topic_id'] = $app-&gt;check_string($_POST['topicid']);
   $q1['klant_id'] = $app-&gt;check_string($_POST['klantid']);
   $q1['ledenpagina_id'] = $app-&gt;check_string($_POST['ledenpaginaid']);
   $app-&gt;insert_query('reacties', $q1, 'id');
   } 
  ?&gt; 
  &lt;form action="" method="post"&gt; &lt;div class="form-group"&gt; 
  &lt;label for="comment"&gt;Reactie:&lt;/label&gt; 
  &lt;textarea class="form-control" name="reactie" rows="3" id="comment"&gt;&lt;/textarea&gt; 
  &lt;input type="hidden" name="klantid" value="&lt;?php echo $_SESSION["klant_id"] ?&gt;"&gt; &lt;input type="hidden" name="topicid" value="&lt;?php echo $actieftopicid ?&gt;"&gt; 
  &lt;input type="hidden" name="ledenpaginaid" value="&lt;?php echo $_SESSION["ledenpagina_id"]; ?&gt;"&gt; 
  &lt;input type="hidden" name="onderreactieID" value="&lt;?php echo $reactie; ?&gt;"&gt; 
  &lt;button type="submit" name="react_btn" class="btn btn-primary"&gt;Plaats reactie&lt;/button&gt; 
  
  &lt;/div&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Summary:</strong></p>
  
  <p>I need the data from the first script ($reactie['id']) when you press the button to fill that in some hidden field. That field needs to go to the database.</p>
  
  <p>So it needs to set that javascript in a hidden field somehow. And when you didnt press anybuttons it needs to be a default 0.</p>