title: writing php code for checked checkboxes dynamically add by javascript
body: <p>I have a code as below to make a table:</p>
  <pre><code>    echo(&quot;&lt;script type='text/javascript'&gt;
  
  var table = document.getElementById('show_member');
  
  // Create an empty &lt;tr&gt; element and add it to the 1st position of the table:
  var row = table.insertRow(i);
  i = i+1;
  // Insert new cells (&lt;td&gt; elements) at the 1st and 2nd position of the new &lt;tr&gt; element:
  var cell1 = row.insertCell(0);
  var cell2 = row.insertCell(1);
  var cell3 = row.insertCell(2);
  var cell4 = row.insertCell(3);
  var cell5 = row.insertCell(4);
  var cell6 = row.insertCell(5);
  var cell7 = row.insertCell(6);
  var cell8 = row.insertCell(7);
  var cell9 = row.insertCell(8);
  var cell10 = row.insertCell(9);
  var cell11 = row.insertCell(10);
  
  // Add some text to the new cells:
  cell1.innerHTML = '$name';
  cell2.innerHTML = '$name2';
  cell3.innerHTML = '$lastname';
  cell4.innerHTML = '$lastname2';
  cell5.innerHTML = '$mellicode';
  cell6.innerHTML = '$estekhdamnum';
  cell7.innerHTML = '$email';
  cell8.innerHTML = '$username';
  cell9.innerHTML = '$password';
  cell10.innerHTML = '$id';
  var checkbox = document.createElement('INPUT');
  ***checkbox.type = 'checkbox';
  checkbox.name = 'mark[]';
  checkbox.value = i-1;
  cell11.appendChild(checkbox);***
  &lt;/script&gt;&quot;);
  </code></pre>
  <p>and a button as below:</p>
  <pre><code>&lt;div class=&quot;container&quot;&gt;
      &lt;input type=&quot;button&quot; class=&quot;form-control&quot; name = &quot;karbar&quot; id =&quot;check&quot; value=&quot;افزودن به لیست کاربران&quot;onclick=&quot;add_karbar1()&quot;/&gt;&lt;br&gt;&lt;br&gt;
  &lt;/div&gt;
  </code></pre>
  <p>and below is my php code to update the table</p>
  <pre><code>&lt;?php
  if(isset($_POST['karbar'])){
      //echo &quot;&lt;script&gt;alert('was selected')&lt;/script&gt;&quot;;
      foreach($_REQUEST['mark'] as $value){
          echo &quot;&lt;script&gt;alert('$value was selected');&lt;/script&gt;&quot;;
      }
  }
  
  
  
  ?&gt;
  </code></pre>
  <p>It gives me this error, why?</p>
  <blockquote>
  <p>Notice: Undefined index: mark in E:\Xampp_installed\htdocs\card\add_karbar.php on line 236</p>
  <p>Warning: Invalid argument supplied for foreach() in E:\Xampp_installed\htdocs\card\add_karbar.php on line 23</p>
  </blockquote>
  <p>How can I recognize checked checkboxes and do php code for each checked checkbox in each row?</p>
  <p>thanks</p>