Please I have two arrays Var subject("goat","man"); Var predicate ("enter", "come");
I want to make a search page that will display the results if the input items matches the two arrays Please help
Please I have two arrays Var subject("goat","man"); Var predicate ("enter", "come");
I want to make a search page that will display the results if the input items matches the two arrays Please help
var subject = ['goat','man'];
var predicate = ['enter', 'come'];
var i;
function my_func(){
var search_value = document.getElementById('search1').value; //the entered value in the searchbox
for(i = 0; i < subject.length && predicate.length; i++){ //Find the item that you enter in searchbox
if(search_value === subject[i]){ //
document.getElementById('demo').innerHTML = subject[i];
}
if(search_value === predicate[i]){
document.getElementById('demo').innerHTML = predicate[i];
}
}
}
<input type="search" id="search1"> <button onclick = "my_func()">Show</button>
<p id="demo"></p>