title: How can I access the values of a checkbox outside of the form action that it is declared in?
body: <p>I successfully created a script that will delete the rows of a table if a checkbox is checked on that row (the checkbox holds the rowID). The checkboxes and button to delete these rows are inside of the same form tags. Now I want to create another button that uses the value of the checkboxes to do a different update statement, but the values of the checkboxes are not appearing in $_POST on this separate page.</p>
  <p>Does anyone know how to make the checkbox values accessible outside of the form action it is inside of? Here is my reduced code for the delete that works:</p>
  <p>The function below is called on PickTicket.php to display a table.</p>
  <pre><code>Function DisplayPickTicket() {
  
  $conn = getDBConnection();
  $sql = &quot;SELECT * FROM dbo.BK_NotesRecord WHERE StatusID = 1 &quot;;
  $stmt = sqlsrv_query( $conn, $sql );
  if ( $stmt === false ) {
      die( print_r( sqlsrv_errors(), true) );
  } 
  
  echo '&lt;form action=&quot;updatepickstatus.php&quot; method=&quot;post&quot;&gt;';
  
  // Delete Checkbox header.
  echo '&lt;th class=&quot;table-header&quot; style=&quot;width:5px;&quot;&gt;';
  echo 'Delete';
  echo '&lt;/th&gt;';   
  
  // Inventory number header.
  echo '&lt;th class=&quot;table-header&quot; style=&quot;width:90px;&quot;&gt;';
  echo 'Inventory #';
  echo '&lt;/th&gt;';   
  
  //InventoryID Header
  echo '&lt;th class=&quot;table-header&quot; style=&quot;width:40px;&quot;&gt;';
  echo 'InventoryID';
  echo '&lt;/th&gt;';   
  
  if (sqlsrv_has_rows($stmt)) {
      while($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)) {
          
          
          echo '&lt;tr&gt;';
          //Delete checkbox
          echo '&lt;td class=&quot;cell&quot;&gt;&lt;div class=&quot;cell&quot;&gt;';
          echo '&lt;input type = &quot;checkbox&quot;  name=&quot;chkbox[]&quot; value= &quot;' .$row['InventoryID']. 
          '&quot;&gt;';
          echo '&lt;/td&gt;';
          // Inventory#
          echo '&lt;td class=&quot;cell&quot;&gt;&lt;div class=&quot;cell&quot;&gt;';
              echo $row[&quot;InventoryNumber&quot;];
          echo '&lt;/td&gt;';
          
          // InventoryID.
          echo '&lt;td class=&quot;cell&quot;&gt;&lt;div class=&quot;cell&quot;&gt;';
          echo $row[&quot;InventoryID&quot;];
          echo '&lt;/td&gt;';
              
      }
      
      }
  
   echo &quot;&lt;tr&gt;&quot;;
   echo &quot;&lt;td&gt;&quot;;
  
   echo &quot;&lt;input type='submit' name='submit' Value='Remove'&gt;&quot;;
   echo '&lt;/form&gt;';
   echo &quot;&lt;/td&gt;&quot;;
   echo &quot;&lt;/tr&gt;&quot;;
  </code></pre>
  <p>This is updatepickstatus.php:</p>
  <pre><code>&lt;?php
  $serverName = &quot;(local)&quot;;
  $connectionOptions = array(&quot;Database&quot;=&gt;&quot;Powerlink&quot;);
  $conn = sqlsrv_connect( $serverName, $connectionOptions);
  if( $conn === false ) {
      echo &quot;Connection failed!&lt;br&gt;&quot;;
      die( print_r( sqlsrv_errors(), true));
  } 
  
  
  if (isset($_POST['chkbox'])) {
  foreach($_POST['chkbox'] as $Update) {
      
      
  $sql = &quot;UPDATE BK_NotesRecord set StatusID = '2' WHERE InventoryID  LIKE '&quot;.$Update.&quot;'&quot;;
  $stmt = sqlsrv_query( $conn, $sql );
  //echo '$ids';
  }
  }
  print_r($_POST);
  
  ?&gt;
  </code></pre>
  <p>^^I want to accomplish this same basic task, but outside of updatepickstatus.php. When applying similar logic to check the values of the selected checkboxes on a <strong>different</strong> I get an empty array. Any thoughts?</p>