The code adaptation was to create another variable with the same function and I missed it thanks to @BDOM, I hope that someone else is useful.
Now, is there a better way to adapt the code that is more correct?
Code in operation:
function Searchcamp() {
var input, filter, table, tr, td, ts, i;
input = document.getElementById("camp0");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
ts = tr[i].getElementsByTagName("td")[1];
if (td && ts) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1 || ts.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
<input type="text" id="camp0" onkeyup="Searchcamp()" placeholder="Search for names.." title="Type in a name">
<table id="myTable">
<tr class="header">
<th style="width:10%;">ID</th>
<th style="width:60%;">Name</th>
<th style="width:40%;">Country</th>
</tr>
<tr>
<td>1</td>
<td>Alfreds Futterkiste</td>
<td>Germany</td>
</tr>
<tr>
<td>2</td>
<td>Berglunds snabbkop</td>
<td>Sweden</td>
</tr>
<tr>
<td>3</td>
<td>Island Trading</td>
<td>UK</td>
</tr>
<tr>
<td>4</td>
<td>Koniglich Essen</td>
<td>Germany</td>
</tr>
</table>