1

好的,我的 index.html 格式如下:

<form action="process.php" method="post">
  <table>
    <tr>
      <td><input name="Field[]" type="checkbox" value="Accounting" />Accounting</td>
      <td><input name="Field[]" type="checkbox" value="Finance" />Finance</td>
      <td><input name="Field[]" type="checkbox" value="Marketing" />Marketing</td>
    </tr>
  </table>
</form>

我有 process.php 如下:

<table>
  <tr>
    <th>Field(s):</th>
    <td>
      <?php
        if(isset($_POST['Field']))
        {
          for($i = 0; $i < count($_POST['Field']); $i++)
          { echo $_POST['Field'][$i] . ' '; }
        }
      ?>
    </td>
  </tr>
</table>

然而由于某种原因,我只打印了最后一个复选框的第一个字母。请帮忙!

4

1 回答 1

5
Try this one in process.php to get the values from $_POST['Field']

   <table>
    <tr>
     <th>Field(s):</th>
     <td>
      <?php
        if(isset($_POST['Field']))
        {
          foreach ($_POST['Field'] as $value) {
            echo $value;
          }
        }
      ?>
     </td>
    </tr>
   </table>
于 2012-04-15T04:45:07.397 回答