-1
By clicking the button, I want to change the row color of an HTML table if it has the same value as my text box. My table:
<table id="tablefc" border="4">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
<tr>
<td>Frank</td>
<td>Nenjim</td>
<td>19</td>
</tr>
<tr>
<td>Alex</td>
<td>Ferreira</td>
<td>23</td>
</tr>
<tr>
<td>Bill</td>
<td>Airman</td>
<td>30</td>
</tr>
<tr>
<td>Ali</td>
<td>Bergen</td>
<td>27</td>
</tr>
</table>
<input type="text" id="searchtxt">
<button onclick="findcolor()">Find and color the row</button>
My Javascript code
function findcolor()
{
var srch = document.getElementById("searchtxt").value;
var index, localizado;
for(var i=1; i < tablefc.rows.length; i++)
{
if (srch === tablefc.rows[i].cells[1].innerHTML)
{
console.log('found');
document.getElementById("searchtxt").value = localizado
} else {
console.log('not found');
}
}