-2

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

  • Can you explain more? or adding some code would be more easier. – dhanushkac Mar 14 '20 at 22:49
  • Your question is too board to help. If you want to check an array for a specific String, see this question. https://stackoverflow.com/questions/6116474/how-to-find-if-an-array-contains-a-specific-string-in-javascript-jquery – Lalith J. Mar 14 '20 at 23:04

1 Answers1

0

        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>