Jump to content

how to make radio button checked php in table dynamique


ab2Info

Recommended Posts

hi,

i want to make radio button checked php in table dynamique 

the problem is when i check the radio button in second rows , the first rows Loses value , 

The same thing occurs with rows
 
--------------------------------------------
 
<body>
 
<h2 align="center">Feuille de Présence Seminaire 1</h2>
<div style="overflow-x:auto;">
  <table>
    <tr>
      <th>Cin</th>
      <th>Nom</th>
      <th>Prenom</th>
      <th>Spécilité</th>
      <th>Le Mois 1</th>
      <th>Le Mois 2</th>
      <th>Le Mois 3</th>
      
 
 
    </tr>
    <?php while($pre=mysqli_fetch_assoc($res)) {?>
    <tr>
      <td><?php echo($pre['cin'])?></td>
      <td><?php echo($pre['nom'])?></td>
      <td><?php echo($pre['prenom'])?></td>
      <td><?php echo($pre['specialite'])?></td>
     <!--Mercredi 04 janvier -->
      <td>
<select name="specialite3">
<option value="matin" <?php if ($pre['specialite']=='matin') {
echo 'selected';}?>/>matin</option>
<option value="Après Midi" <?php if ($pre['specialite']=='Après Midi') {echo 'selected';}?>/>Après Midi</option>
</select>
<input type="radio" value="Oui" name="gender" <?php if ($pre['specialite']=="Oui") {echo "checked";}?>/>Oui
<input type="radio" value="Non" name="gender"<?php if ($pre['specialite']=="Non") echo "checked";?>/>Non
</td>
<!--Mercredi 04 janvier -->
<td><select name="specialite3">
<option value="matin" <?php if ($pre['specialite']=='matin') {
echo 'selected';}?>/>matin</option>
<option value="Après Midi" <?php if ($pre['specialite']=='Après Midi') {echo 'selected';}?>/>Après Midi</option>
</select>
 
  </td>
<!--Mercredi 04 janvier -->
<td><select name="specialite3">
<option value="matin" <?php if ($pre['specialite']=='matin') {
echo 'selected';}?>/>matin</option>
<option value="Après Midi" <?php if ($pre['specialite']=='Après Midi') {echo 'selected';}?>/>Après Midi</option>
</select></td>
    </tr>
 <?php }?>
  </table>
 <div align="center"> <button class="button"><span>Enregistrer </span></button></div>
</div>
 
</body>
Edited by ab2Info
Link to comment
Share on other sites

To maintain the selection for each person, you need to use unique values for the name attributes in the <input> tag. For example

<label><input type="radio" value="Oui" name="gender1" <?php if ($pre['specialite']=="Oui") {echo "checked";}?>/>Oui</label>
<label><input type="radio" value="Non" name="gender1"<?php if ($pre['specialite']=="Non") echo "checked";?>/>Non</label>
 
...
 
<label><input type="radio" value="Oui" name="gender2" <?php if ($pre['specialite']=="Oui") {echo "checked";}?>/>Oui</label>
<label><input type="radio" value="Non" name="gender2"<?php if ($pre['specialite']=="Non") echo "checked";?>/>Non</label>
 
Note the "gender1" and "gender2" values.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.