tam42025
04-23-2003, 01:25 PM
Someone please help me! I am trying desperately to manipulate this code to search for more then one option when the submit button is pressed. I have written in red what I changed in this script. What I want to do is when one of the options are selected, I want the code to limit the search to only what was selected. I thought all I had to do was just enter a name and a value for each of the inputs and call those names in the script, it would work. What I tried to do is in red in the script. Can someone tell me what I did wrong.
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Dion (biab@iinet.net.au) -->
<!-- Web Site: http://www.iinet.net.au/~biab -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var item = new Array();
/* Here is where all the magic happens.
Just enter as many additional pages that
that you want to search, then fill in the
additional listings for each page.
*/
// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"
c=0; item[c]=new Array
("","activaladySV233-002.htm","Activa Lady Stainless Steel SV233-002","SV233-002,activa ladies watches,lady,37.50,stainless steel watches,black face,swiss quartz movement","Activa Ladies Watch, stainless steel case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySV235-005.htm","Activa Lady Stainless Steel SV235-005","SV233-005,lady,activa ladies watches,37.50,stainless steel watches,gold tone face,swiss quartz movement","Activa Ladies Watch, stainless steel case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySV235-006.htm","Activa Lady Gold Tone SV235-006","SV235-006,lady,activa ladies watches,37.50,stainless steel watches,black face,swiss quartz movement","Activa Ladies Watch, gold tone case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySB437403.htm","Activa Lady Two Tone Stainless Steel SB437-403","SB437-403,lady,activa ladies watches,37.50,stainless steel watches,gold tone face,swiss quartz movement","Activa Ladies Watch, two tone case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySB437404.htm","Activa Lady Two Tone Stainless Steel SB437-404","SB437-404,lady,activa ladies watches,37.50,stainless steel watches,white face,swiss quartz movement","Activa Ladies Watch, two tone case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySV233-100.htm","Activa Lady Stainless Steel SV233-100","SV233-100,lady,activa ladies watches,37.50,stainless steel watches,white face,swiss quartz movement","Activa Ladies Watch, stainless steel case with swiss registry 49594...");
page="<html><head><title>Search Results</title></head><body bgcolor='white'><center><table border=0 cellspacing=10 width=80%><font size=5>TTS Merchandise.com <font color=red>Search Results</font><br>";
function search(frm) {
win = window.open("","","scrollbars");
win.document.write(page);
txt = frm.srchval.value.split(" ") + frm.brand.options[].text + frm.itemn.value + frm.loprice.options[].text + frm.hiprice.options[].text
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write("</table><br>Total found: "+total+"<br></body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Score: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>";
wind.document.write(line);
return 1;
}
// End -->
</script>
</HEAD>
<body>
<form method=get action="javascript:void(0)" onsubmit="search(this); return false;" name="search_a">
<table width="654"><tr><td width="309"><b>Keywords:
</b><input type=text name=srchval value=""></td><td width="331"><b>Watch
Brands: </b><select size="1" name="brand">
<option value="">All Brands</option>
<option selected value="">Activa</option>
<option value="">Bulova</option>
<option value="">Calvin Klein</option>
<option value="">Casio</option>
<option value="">Citizen</option>
<option value="">Colibri</option>
<option value="">Croton</option>
<option value="">Esq</option>
<option value="">Festina</option>
<option value="">Fossil</option>
<option value="">Gucci</option>
<option value="">Invicta</option>
<option value="">Kenneth Cole</option>
<option value="">Lassale</option>
<option value="">Luminox</option>
<option value="">Movado</option>
<option value="">Nike</option>
<option value="">Omega</option>
<option value="">Pulsar</option>
<option value="">Rado</option>
<option value="">Skaggen</option>
<option value="">Seiko</option>
<option value="" >Swatch</option>
<option value="">Swiss Army</option>
<option value="">Tag</option>
<option value="">Timex</option>
<option value="">Vanceur</option>
<option value="">Visage</option>
<option value="">Wittnauer</option>
<option value="">Wenger</option>
</select></td></tr>
<tr><td width="309"><b>Item Number </b><input type=text name=itemn></td><td width="331"><b>Starting
Price: </b> </td<td> <select NAME="loprice">
<option VALUE="25">$From
<option VALUE="50">$50
<option VALUE="100">$100
<option VALUE="150">$150
<option VALUE="200">$200
<option VALUE="300">$300
<option VALUE="400">$400
<option VALUE="500">$500
<option VALUE="600">$600
<option VALUE="800">$800
<option VALUE="1000">$1,000
<option VALUE="1500">$1,500
<option VALUE="2000">$2,000
<option VALUE="4000">$4,000
<option VALUE="6000">$6,000
</select>
<b>Ending Price: </b> <select NAME="hiprice">
<option value="10000">$To
<option VALUE="10000">$10,000
<option VALUE="6000">$6,000
<option VALUE="4000">$4,000
<option VALUE="2000">$2,000
<option VALUE="1500">$1,500
<option VALUE="1000">$1,000
<option VALUE="800">$800
<option VALUE="600">$600
<option VALUE="500">$500
<option VALUE="400">$400
<option VALUE="300">$300
<option VALUE="200">$200
<option VALUE="150">$150
<option VALUE="100">$100
<option VALUE="50">$50
</select>
</td></tr><tr><td width="309">
<p align="right"><input type=submit value="Search"></p>
</td></tr></table>
</form>
<!-- Script Size: 3.16 KB -->
</body>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Dion (biab@iinet.net.au) -->
<!-- Web Site: http://www.iinet.net.au/~biab -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var item = new Array();
/* Here is where all the magic happens.
Just enter as many additional pages that
that you want to search, then fill in the
additional listings for each page.
*/
// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"
c=0; item[c]=new Array
("","activaladySV233-002.htm","Activa Lady Stainless Steel SV233-002","SV233-002,activa ladies watches,lady,37.50,stainless steel watches,black face,swiss quartz movement","Activa Ladies Watch, stainless steel case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySV235-005.htm","Activa Lady Stainless Steel SV235-005","SV233-005,lady,activa ladies watches,37.50,stainless steel watches,gold tone face,swiss quartz movement","Activa Ladies Watch, stainless steel case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySV235-006.htm","Activa Lady Gold Tone SV235-006","SV235-006,lady,activa ladies watches,37.50,stainless steel watches,black face,swiss quartz movement","Activa Ladies Watch, gold tone case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySB437403.htm","Activa Lady Two Tone Stainless Steel SB437-403","SB437-403,lady,activa ladies watches,37.50,stainless steel watches,gold tone face,swiss quartz movement","Activa Ladies Watch, two tone case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySB437404.htm","Activa Lady Two Tone Stainless Steel SB437-404","SB437-404,lady,activa ladies watches,37.50,stainless steel watches,white face,swiss quartz movement","Activa Ladies Watch, two tone case with swiss registry 49594...");
c++; item[c]=new Array
("","activaladySV233-100.htm","Activa Lady Stainless Steel SV233-100","SV233-100,lady,activa ladies watches,37.50,stainless steel watches,white face,swiss quartz movement","Activa Ladies Watch, stainless steel case with swiss registry 49594...");
page="<html><head><title>Search Results</title></head><body bgcolor='white'><center><table border=0 cellspacing=10 width=80%><font size=5>TTS Merchandise.com <font color=red>Search Results</font><br>";
function search(frm) {
win = window.open("","","scrollbars");
win.document.write(page);
txt = frm.srchval.value.split(" ") + frm.brand.options[].text + frm.itemn.value + frm.loprice.options[].text + frm.hiprice.options[].text
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write("</table><br>Total found: "+total+"<br></body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Score: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>";
wind.document.write(line);
return 1;
}
// End -->
</script>
</HEAD>
<body>
<form method=get action="javascript:void(0)" onsubmit="search(this); return false;" name="search_a">
<table width="654"><tr><td width="309"><b>Keywords:
</b><input type=text name=srchval value=""></td><td width="331"><b>Watch
Brands: </b><select size="1" name="brand">
<option value="">All Brands</option>
<option selected value="">Activa</option>
<option value="">Bulova</option>
<option value="">Calvin Klein</option>
<option value="">Casio</option>
<option value="">Citizen</option>
<option value="">Colibri</option>
<option value="">Croton</option>
<option value="">Esq</option>
<option value="">Festina</option>
<option value="">Fossil</option>
<option value="">Gucci</option>
<option value="">Invicta</option>
<option value="">Kenneth Cole</option>
<option value="">Lassale</option>
<option value="">Luminox</option>
<option value="">Movado</option>
<option value="">Nike</option>
<option value="">Omega</option>
<option value="">Pulsar</option>
<option value="">Rado</option>
<option value="">Skaggen</option>
<option value="">Seiko</option>
<option value="" >Swatch</option>
<option value="">Swiss Army</option>
<option value="">Tag</option>
<option value="">Timex</option>
<option value="">Vanceur</option>
<option value="">Visage</option>
<option value="">Wittnauer</option>
<option value="">Wenger</option>
</select></td></tr>
<tr><td width="309"><b>Item Number </b><input type=text name=itemn></td><td width="331"><b>Starting
Price: </b> </td<td> <select NAME="loprice">
<option VALUE="25">$From
<option VALUE="50">$50
<option VALUE="100">$100
<option VALUE="150">$150
<option VALUE="200">$200
<option VALUE="300">$300
<option VALUE="400">$400
<option VALUE="500">$500
<option VALUE="600">$600
<option VALUE="800">$800
<option VALUE="1000">$1,000
<option VALUE="1500">$1,500
<option VALUE="2000">$2,000
<option VALUE="4000">$4,000
<option VALUE="6000">$6,000
</select>
<b>Ending Price: </b> <select NAME="hiprice">
<option value="10000">$To
<option VALUE="10000">$10,000
<option VALUE="6000">$6,000
<option VALUE="4000">$4,000
<option VALUE="2000">$2,000
<option VALUE="1500">$1,500
<option VALUE="1000">$1,000
<option VALUE="800">$800
<option VALUE="600">$600
<option VALUE="500">$500
<option VALUE="400">$400
<option VALUE="300">$300
<option VALUE="200">$200
<option VALUE="150">$150
<option VALUE="100">$100
<option VALUE="50">$50
</select>
</td></tr><tr><td width="309">
<p align="right"><input type=submit value="Search"></p>
</td></tr></table>
</form>
<!-- Script Size: 3.16 KB -->
</body>