Buon giorno, ho questo problemino.Ho preso uno script per la ricerca sul web, vorrei sostituire la select option con una input, ma restituisce l'errore che non trova il valore della input.
codice:
function addplus(items) {
var plussed = "";
for (var t = 1 ; t <= items.length ; t++) {
if (items.substring(t-1,t) == " ") {
plussed+="+";
}
else {
plussed+=items.substring(t-1,t);
}
}
return plussed;
}
//
// Do the Search
//
function doSearch() {
var words;
words = document.searchforit.query.value;
var searchitems;
searchitems=addplus(words);
var index;
//
// Obtain the selectedIndex properties from the search engines options for
//
index = document.searchforit.service.selectedIndex;
//index = document.searchforit.service.value;
var site;
site = document.searchforit.service.options[index].value;
//site = document.searchforit.service.input.value;
site+=searchitems;
if (notEmpty(searchitems)) {
window.open("","mainWin");
window.open(site,"mainWin");
}
}
//
// Check for empty contents in search searchitems
//
function notEmpty(word) {
if (word == "" || word == null) {
self.status="ENTER SEARCH searchitems";
//alert("Do you really want to look for nothing, Please enter SEARCH FOR items");
alert("Per effettuare la ricerca devi inserire una o più parole..");
return false;
}
else {
self.status = "SEARCHING FOR: " + word;
return true;
}
}
//
//Exit Window
//
function ConfirmClose() {
if (confirm("Do you really wish to exit ?")) {
window.close()
}
}
<FORM NAME="searchforit" ACTION="javascript:doSearch()" method="GET" TARGET="mainWin" onSubmit="doSearch()">
Search for:
<input name="query" size="20" onFocus="self.status='Type in keywords tosearch for, hit Go Get It or select the search engine.'; return true" onSubmit="doSearch()" onBlur="document.searchforit.query.value=this.value">
[img]img/icoGoogle.jpg[/img]
<select name="service" onChange="doSearch()" TARGET="_new"><option value="http://www.google.it/search?hl=it&btnG=Cerca+con+Google&meta=lr%3Dlang_it&q=">Google</option></select>
<input class="INPUT" type="button" style="width:50px;" name="formbutton" value="Search!" onClick="doSearch()" TARGET="_new">
</FORM>
il problema credo sia qui, ma non so come fare:
codice:
index = document.searchforit.service.selectedIndex;
//index = document.searchforit.service.value;//sbagliato
var site;
site = document.searchforit.service.options[index].value;
//site = document.searchforit.service.input.value;//sbagliato
Un aiuto per favore..Grazie mille...