I am currently working on a code that displays the results of a query in a table format. I would like to have the ability to click on certain elements to show or hide them. I know this can be achieved using toggle and CSS, but I keep encountering obstacles. Here is a snippet of my code:
The code generates rows for the table based on the query results which are echoed out.
$fields .= "<tr class='viewed' id='".$job_id."' style=".$new_table."><td scope='row' data-label='Date' style='".$new_table."'>".$new_date."</td><td data-label='Pickup'>".$p_city."</td><td data-label='Destination'>".$d_city."</td><td data-label='Pax'>".$pax."</td><td data-label='Vehicle'>".$vehicle_required."</td><td data-label='Status'>".$bidded." (<B>".$bid_count."</B>) </td></td><td width='50px'><button type='button' data-name='".$job_id."' class='btn btn-success'><span class='glyphicon glyphicon-zoom-in'></span> View job </button></td></tr>";
$fields .= "<tr class='unviewed' id='".$job_id."' style=".$new_table."><td scope='row' data-label='Date' style='".$new_table...etc
...
<p>The code I have for implementing checkboxes is as follows:</p>
<pre><code><div class="container">
<h2>Form control: inline checkbox</h2>
<p>The form below contains three inline checkboxes:</p>
<form>
<label class="checkbox-inline">
<input type="checkbox" value="">Show viewed
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Show unviewed
</label>
<label class="checkbox-inline">
<input type="checkbox" value="">Show outofrange
</label>
</form>
</div>
In order to toggle the display when clicked, here is the CSS that needs to be toggled:
.viewed {
display: none;
}
.outofrange {
display: none;
}
.unviewed {
display: none;
}
How can I implement a toggle functionality to change between show/hide when clicked?
Thank you