mardi 25 juillet 2017

Show/Hide HTML table column based on radio button selection

I have a HTML table that is displaying data from database for three different MySQL conditions. I want to hide one column for one radio option. I have looked around a lot but not reaching upto the point. Any suggestion or help will be appreciated.

This is the HTML table that is displaying data

<thead>
  <tr>
  <th>S.No.</th>
  <th>Email ID</th>
  <th>SBI Employee ID</th>
  <th>Name</th>
  <th>Mobile No.</th>
  <th>Date of Birth</th>
  <th>Registration Date</th>
  <th>Check for Approval 
       <input type="checkbox" id="select_all" name="all_check[]" <?php echo $disabled ;?> class="checkbox" value= "<?php echo $row['id']; ?>"> </th></tr>
 </thead>

Now I have my MySQL queries as,

switch ($users)
        {
        case "all":
          $sqlQuery = "SELECT * FROM tbl_user WHERE type =3";
        break;
        case "approved":
           $sqlQuery = "SELECT * FROM tbl_user WHERE type =3 AND status =1";
        break;
        case "unapproved":
          $sqlQuery = "SELECT * FROM tbl_user WHERE type =3 AND status =0";
        break;
      }

And now the radios,

 <input type='radio'  name='users' value='unapproved' <?php if (isset($_POST['users']) && $_POST['users'] == 'unapproved')  echo ' checked="checked"';?> checked /> Unapproved Candidates<br> 
          <input type='radio'  name='users' value='approved' <?php if (isset($_POST['users']) && $_POST['users'] == 'approved') echo ' checked="checked"';?> / > Approved Candidates<br>
          <input type='radio' id='show' name='users' value='all'  <?php if (isset($_POST['users']) && $_POST['users'] == 'all')  echo ' checked="checked"';?> /> All Candidates<br><br> 
          <input type="submit" value="submit" id="submit"><br><br> 

What I want to do is to hide the "Check for approval" column for "All Candidates" radio selection and to show the checkbox field in it as disabled for"approved user" selection. I am new to php and still wondering about this as I have known till now that it can be done only by jquery. Please pardon for the mistakes I have put in here but looking for some solution to this. Thanks




Aucun commentaire:

Enregistrer un commentaire