How will i pass the arguments to filterText() method,because i'll be calling the same method at more than one place , id is 'filterText' and class name is 'content' , these 2 values i want to pass as a parameter.
function filterText() {
var rex = new RegExp($('#filterText').val());
if (rex == "/all/") {
clearFilter()
} else {
$('.content').hide();
$('.content').filter(function() {
return rex.test($(this).text());
}).show();
}
}
function clearFilter() {
$('.filterText').val('');
$('.content').show();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="TestCase" class="table table-bordered table-striped table-condensed table-hover table-list-search">
<thead>
<tr name="Test Module_Header" class="danger">
<th>
Module Name
</th>
<td colspan="4">
<strong> CashableCredits</strong>
</td>
</tr>
<tr name="Test case Header" class="info">
<th style="width: 160px">
TestCase Name
</th>
<th style="width: 160px">
Scenario Details
</th>
<th style="width: 110px">
Status
<select id='filterText' style='display:inline-block' onchange='filterText()'>
<!--i want to parametrize this id 'filterText' -->
<option disabled selected>Select</option>
<option value='Passed'> Passed</option>
<option value='Failed'> Failed</option>
<option value='Blocked'> Blocked</option>
<option value='all'> All</option>
</select>
</th>
<th style="width: 160px">
Start Time
</th>
<th style="width: 160px">
End Time
</th>
<th style="width: 170px">
Total Time Taken
</th>
<th style="width: 170px">
Iteration Count
</th>
<th style="width: 140px">
Exception Stack
</th>
<th style="width: 140px">
Test Case IDs
</th>
<th style="width: 140px">
Screenshot
</th>
</tr>
</thead>
<tbody>
<tr name="Script Details" class="content">
<!-- i want to parameterize this class name 'content' -->
<td>
<a href="javascript:;" onclick="toggle_visibility('redeemCashableCreditLoadedThroughCashier')">redeemCashableCreditLoadedThroughCashier</a>
</td>
<td>
<a href="javascript:;" onclick="toggle_visibility('Verify player able to redeem the cashable credit loaded through the cashier');">View </a>
</td>
<td>
<font style="color: green;"> Passed</font>
</td>
<td>
25/04/17 11:55:30
</td>
<td>
25/04/17 12:07:39
</td>
<td>
0h :12m :9s
</td>
<td>
1
</td>
<td>
<a href="javascript:;" onclick="toggle_visibility('');">Click Here
</a>
</td>
<td>
<a href="javascript:;" onclick="toggle_visibility('');">View </a>
</td>
<td>
<a href="javascript:;" onclick="toggle_visibility('redeemCashableCreditLoadedThroughCashier_screenshot');">Click Here </a>
</td>
</tr>
In the above html , i want to parametrize id('filterText') & class name('content') to the javascript function.