I'll pseudocode this to begin:
array = copper, oil, silver, bronze, gold, iron user inputs the letter 'l' if (the input has the letter 'l', remove everything from the array except words with 'l') { output = copper, bronze, iron
my code:
//arr = iron, oil, gold, silver, bronze classDiv = document.getElementsByClassName("searchOutputName"); for(var i = 0; i < arr.length; i++){ market = arr[i]; var n = market.indexOf(userInput.value); if (n >= 0) { classDiv[i].appendChild(document.createTextNode(arr[i])); } else { //do nothing }
I have 5 div boxs for my search function.
If the user inputs 'l' the first box is empty, then it says oil, gold, silver, then another empty box. I want to make it so they stack up... first box has oil, then gold, then silver then 2 empty boxs.