var prods = new Array(); function findRightProduct(theform) { //reset the answer resetAnswer(prods.length) ; closeDefault(true); var finalone = 0; var form = document.theselector; if (theform == "Tips") { f_find = form.Coatings.options[form.Coatings.selectedIndex].value ; r_find = form.Surfaces.options[form.Surfaces.selectedIndex].value ; } else if (theform == "Sprayer") { f_find = form.Gallons.options[form.Gallons.selectedIndex].value ; r_find = form.Material.options[form.Material.selectedIndex].value ; c_find = form.HowOften.options[form.HowOften.selectedIndex].value ; s_find = form.Surfaces.options[form.Surfaces.selectedIndex].value ; } //find any product this might work for var foundone = false; for(var i = 1; i <= prods.length; i++) { if (prods[i] != null) { var prod_array= prods[i].split("+"); if (theform == "Tips") { if (prod_array[0] == f_find && prod_array[1] == r_find) { openAnswer(i, "open", prods.length); } } else if (theform == "Sprayer") { if (prod_array[0] == f_find && prod_array[1] == r_find && prod_array[2] == c_find && prod_array[3] == s_find) { openAnswer(i, "open", prods.length); } } } } } function resetAnswer(c) { //need to hide all to start for(var k = 1; k <= c ;k++) { var h1 = document.getElementById("Answer_" + k); if (h1 != null) { h1.style.display="none"; } } } function closeDefault(swt) { //hide the default line if (swt) { var r1 = document.getElementById("Answer_0"); r1.style.display="none"; } else { var r1 = document.getElementById("Answer_0"); r1.style.display=""; } } // open right answer display function openAnswer(a, b, c) { //need to hide all to start for(var k = 1; k <= c ;k++) { var h1 = document.getElementById("Answer_" + k); if (h1 != null) { h1.style.display="none"; } } //then open the right one var r1 = document.getElementById("Answer_" + a); if(r1){ if (b == "open") { closeDefault(true); if( r1.style.display =="none") { r1.style.display=""; } } else { if( r1.style.display =="") { r1.style.display="none"; } }} }