Select only one item

Asked

Viewed 146 times

2

Here’s the code:

<?php while($ver=mysql_fetch_row($busca)){ ?>
    <tr>
        <td><input type="radio" value="<?php echo "$var[0]"; ?>"></td><td><?php echo "$ver[0]"; ?></td>
        <td><?php echo "$ver[1]"; ?></td>
        <td><?php echo "$ver[2]"; ?></td>
        <td><?php echo "$ver[3]"; ?></td>
        <td><?php echo "$ver[4]"; ?></td>
    </tr>                  
<?php } ?>

And here only one should be selected, but that’s not what’s happening: inserir a descrição da imagem aqui

2 answers

3


Missing "name" element inside radio input so that only one can be selected.

<tr>
  <td>
    <input type="radio" value="1" name="group1" />
  </td>
  <td>1</td>
  <td>Col 2</td>
  <td>Col 3</td>
  <td>Col 4</td>
  <td>Col 5</td>
</tr>

<tr>
  <td>
    <input type="radio" value="2" name="group1" />
  </td>
  <td>2</td>
  <td>Col 2.2</td>
  <td>Col 3.2</td>
  <td>Col 4.2</td>
  <td>Col 5.2</td>
</tr>

<tr>
  <td>
    <input type="radio" value="3" name="group1" />
  </td>
  <td>3</td>
  <td>Col 2.3</td>
  <td>Col 3.3</td>
  <td>Col 4.3</td>
  <td>Col 5.3</td>
</tr>

0

Try to use as your first ID field, ie using $ver[1] and use the attribute name.

<input type="radio" value="<?php echo "$ver[0]"; ?>" name="selecionado" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.