jstestpager
02-24-2008, 10:39 PM
I am in an online js class and we have to create a search based on the description of 3 items, but my search always returns 0 results. What is wrong with it? Here is the function:
function doSearch(){ //start doSearch and lab 6
searchvalue = document.searchbox.searchterm.value
lowervalue = searchvalue.toLowerCase()
adventures_of_fin = "Adventures Huckleberry Fin 45U345H1 classic all ages Mark Twain $8.95".toLowerCase()
call_of_wild = "Call Wild 5AF834HA renowned Jack London paperback $6.95".toLowerCase()
don_quixote = "Don Quixote 6H78T8T6 famous Spanish hero Miguel de Cervantes $11.95".toLowerCase()
switch(lowervalue) { //start switch
case adventures_of_fin.indexOf(lowervalue) > -1:
document.write("<b>Your search for " + searchvalue + " returned the following result:</b><br>" + buildProduct("Adventures of Huckleberry Fin","45U345H1","A classic for all ages by Mark Twain. Hardcover for only $8.95"))
break
case call_of_wild.indexOf(lowervalue) > -1:
document.write("<b>Your search for " + searchvalue + " returned the following result:</b><br>" + buildProduct("The Call of the Wild","5AF834HA","The renowned novel by Jack London in paperback for only $6.95"))
break
case don_quixote.indexOf(lowervalue) > -1:
document.write("<b>Your search for " + searchvalue + " returned the following result:</b><br>" + buildProduct("Don Quixote","6H78T8T6","The famous novel of a Spanish hero by Miguel de Cervantes. Hardcover for only $11.95"))
break
default:
document.write("<b>Sorry we could not find anything matching your query, " + searchvalue + ". Suggestions:<br>- Check that all words are spelled correctly.<br>- Try new keywords.<br>- Try less specific keywords. <input type=button value='Back' onClick='history.go(-1)'>"
+ "</TD></TR><TR BGCOLOR='#00CCFF'><TD ROWSPAN=1 COLSPAN=1>"
+ "<IFRAME SRC='http://www.freewebs.com/jstestpage/iframe.htm'"
+ "WIDTH='100%' HEIGHT='58%' NAME='productarea'"
+ "frameborder='0' marginheight='0'>"
+ "Warning your Browser does not support IFRAMES"
+ "</IFRAME>")
break
} //end switch
} //end doSearch and lab 6
function doSearch(){ //start doSearch and lab 6
searchvalue = document.searchbox.searchterm.value
lowervalue = searchvalue.toLowerCase()
adventures_of_fin = "Adventures Huckleberry Fin 45U345H1 classic all ages Mark Twain $8.95".toLowerCase()
call_of_wild = "Call Wild 5AF834HA renowned Jack London paperback $6.95".toLowerCase()
don_quixote = "Don Quixote 6H78T8T6 famous Spanish hero Miguel de Cervantes $11.95".toLowerCase()
switch(lowervalue) { //start switch
case adventures_of_fin.indexOf(lowervalue) > -1:
document.write("<b>Your search for " + searchvalue + " returned the following result:</b><br>" + buildProduct("Adventures of Huckleberry Fin","45U345H1","A classic for all ages by Mark Twain. Hardcover for only $8.95"))
break
case call_of_wild.indexOf(lowervalue) > -1:
document.write("<b>Your search for " + searchvalue + " returned the following result:</b><br>" + buildProduct("The Call of the Wild","5AF834HA","The renowned novel by Jack London in paperback for only $6.95"))
break
case don_quixote.indexOf(lowervalue) > -1:
document.write("<b>Your search for " + searchvalue + " returned the following result:</b><br>" + buildProduct("Don Quixote","6H78T8T6","The famous novel of a Spanish hero by Miguel de Cervantes. Hardcover for only $11.95"))
break
default:
document.write("<b>Sorry we could not find anything matching your query, " + searchvalue + ". Suggestions:<br>- Check that all words are spelled correctly.<br>- Try new keywords.<br>- Try less specific keywords. <input type=button value='Back' onClick='history.go(-1)'>"
+ "</TD></TR><TR BGCOLOR='#00CCFF'><TD ROWSPAN=1 COLSPAN=1>"
+ "<IFRAME SRC='http://www.freewebs.com/jstestpage/iframe.htm'"
+ "WIDTH='100%' HEIGHT='58%' NAME='productarea'"
+ "frameborder='0' marginheight='0'>"
+ "Warning your Browser does not support IFRAMES"
+ "</IFRAME>")
break
} //end switch
} //end doSearch and lab 6