JSFiddle - React, Tailwind, and code Playground
HTML
<table border="1">
<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[]" />
</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
</tbody>
</table>
<input type='radio' name='users' value='unapproved' /> Unapproved Candidates<br>
<input type='radio' name='users' value='approved' /> Approved Candidates<br>
<input type='radio' id='show' name='users' value='all' /> All Candidates<br><br>
<input type="submit" value="submit" id="submit"><br><br>
JavaScript
var users = "all";
/* change the above line to:
* var users = "<?php if (isset($_POST['users'])) echo $_POST['users']; ?>";
*/
(function(users){
// check if PH
if (users.length) {
// update the radio option...
var inputTag = document.querySelector('input[value="'+users+'"]');
if (inputTag)
inputTag.checked = true;
// if users is "all"
// hide the last TD of every column
if (users == "all") {
var lastTh = document.querySelector('tr th:last-child');
lastTh.style.display = "none";
var allLastTds = document.querySelectorAll('td:last-child');
for (var i = 0; i< allLastTds.length; i++) {
allLastTds[i].style.display="none";
}
}
// if users is "approved"
// make the checkbox disabled
if (users == "approved") {
thInputTag = document.getElementById("select_all");
thInputTag.setAttribute("disabled", true);
}
}
})(users);