In this example ill have a filter function but it will only search value in the table if i type inside the input text field, so i what i need help on is that i want that this function filters data when the input is changed by code not by a user inserting text inside the input.
<script>
$(document).ready(function(){
$("#txtSearch").on("change", function() {
var value = $(this).val().toLowerCase();
$("#tblSearch tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
This second script will change the value of the txtSearch input to explain how i want the filter option to be working. By a changed input but not when a user type on it.
function selectedRow(){ var index, table = document.getElementById('taCiclo');
for(var i = 1; i < table.rows.length; i++)
{
table.rows[i].onclick = function()
{
document.getElementById("id_ciclo").value = this.cells[0].innerHTML;
//i've tried the trigger or eventDispatcher is this part too, but is not working at all.
document.getElementById("id_ciclo").value ;
if(typeof index !== "undefined"){
table.rows[index].classList.toggle("selected");
}
console.log(typeof index);
index = this.rowIndex;
this.classList.toggle("selected");
console.log(typeof index);
};
}
}
selectedRow();