I have a dropdown and a table in an HTML form. I need to filter the table's appearance using the dropdown. The dropdown has four values. If the value 'All' is selected the table should show the entire table. Else the table should show contents as per the value selected in the dropdown table. The table looks like this: enter image description here
This the code:
#mytable {
width: 100%;
border-collapse: collapse;
}
.tr {
background: #808080;
color: white;
font-weight: bold;
}
#mytable tb {
padding: 5px;
border: 1px solid black;
text-align: left;
}
#optionsDiv {
padding-bottom: 10px;
font-weight: bold;
}
#selectField {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
border: 1px solid #ccc;
font-size: 16px;
height: 30px;
width: 200px;
}
.odd {
background: #ccffeb;
}
.even {
background: #99FFD6;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div class="container" style="margin-top:150px;">
<h1>Paleetu provides a variety of BPM related courses.</h1><br>
<p> Please select a course from below dropdown</p>
<select id="myfilter" onchange="myfunction()">
<option value="all">All Course</option>
<option value="pegacsa">Pega CSA</option>
<option value="pegacssa">Pega CSSA</option>
<option value="camunda">Camunda BPM</option>
</select>
<table id="mytable" class="table table-bordered">
<tbody>
<tr class="content">
<th>Start</th>
<th>End</th>
<th>Time</th>
<th>Course</th>
<th>Price</th>
<th>Credits</th>
<th>Location</th>
</tr>
<tr class="content">
<td>1st April 2020</td>
<td>17th April 2020</td>
<td>9:30AM to 12:30PM</td>
<td>Pega CSA</td>
<td>Rs. 14,000</td>
<td>125</td>
<td>Bengaluru</td>
</tr>
<tr class="content">
<td>1st April 2020</td>
<td>17th April 2020</td>
<td>1:30PM to 5:30PM</td>
<td>Pega CSSA</td>
<td>Rs. 14,000</td>
<td>50</td>
<td>Bengaluru</td>
</tr>
<tr class="content">
<td>1st April 2020</td>
<td>17th April 2020</td>
<td>1:30PM to 5:30PM</td>
<td>Camunda BPM</td>
<td>Rs. 14,000</td>
<td>90</td>
<td>Bengaluru</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Can someone please help me filter the table using dropdown value using js or jquery.