Click to See Complete Forum and Search --> : Advanced Search Help Please........


tam42025
04-18-2003, 12:16 PM
I have a javascript I want to add to my site from javascriptsource. I have yet to add it to my site because I want to do more with it. I vaguely understand javascript and I have searched every where for a script to do what I want. This script comes the closest. The only thing is with this script, which is a search script allowing viewers to search my site, it is pretty basic. I would like to turn this basic search script into a more advanced search but I don't know how. I have tried to use the select and option value tags in there but it doesn't work for me. I am going to list the script below and I was wondering if someone can help me alter it to do these things:

I want a drop down menu that allows them to select the name brand watches I have.
I want a box that allows them to put in additional keywords
and I want a drop down menu that allows them to choose a price range starting at and ending at. Something like this example

CLICK HERE (http://www.watchwholesalers.com/showwatches.asp?brand=activa&sort1=discount&sortcd1=1&category=0&lowpercent=0&highpercent=100)

Now Here's The Code:-----
<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var item = new Array();

// "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...");
c++; item[c]=new Array
("","activaladySV241-001.htm","Activa Lady Stainless Steel SV241-001","SV241-001,lady,activa ladies watches,37.50,stainless steel watches,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%>";


function search(frm) {
win = window.open("","","scrollbars");
win.document.write(page);
txt = frm.srchval.value.split(" ");
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>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>

<form method=get action="javascript:void(0)" onsubmit="search(this); return false;">
<tr><td><input type=text name=srchval value=""><input type=submit value="Search"></td></tr>
</form>

</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
----


I am not asking that someone code it for me but just tell me if I can use the select tags with this code and how I would go about doing it.

Thank you! I really appreciate it.

DrDaMour
04-18-2003, 12:48 PM
the javascript to get options is like so:


for a form id="formed" <form id="formed"...
with a select tag id="yes" <secect id="tes"....


teh javacsript objects are


document.forms.yes.length is the amount of options
document.forms.yes.options[index].value is the value of the indexed option

document.forms.yes.options[index].text is the value of the displayed text in the select box


look
here (http://developer.netscape.com/docs/manuals/js/client/jsref/select.htm)

tam42025
04-18-2003, 01:12 PM
I am confused!!!!!!! lol At the bottom of that link you gave me I recognized those codes.

<select>
<option></option>
</select>

I tried to use those codes with my script and it didn't work. What I am wondering is if I need to add some type of additional code to get my search query to recognize that I want these values to be entered as well when my viewer clicks go or whatever.

this is what I tried to do in that code:

<form method=get action="java script:void(0)" onsubmit="search(this); return false;"> <tr><td><select size="1" name="brand">
<option value="any">All Brands</option>

<option selected>Activa</option>

<option >Bulova</option>

<option >Calvin Klein</option>

<option >Casio</option></td></tr>
<tr><td><input type=text name=srchval value=""><input type=submit value="Search"></td></tr>
</form>

So, my question is do I need to add something in the javascript code that I listed in my first message to get the search query to recognize that I want to include this selection in my search.

I hope that makes sense. Thanks again?

tam42025
04-18-2003, 03:31 PM
Like I said in another post I am not that advanced in javascript. I found a code here that allows my visitors to search my site. It works great because I have over 600 watches on my site and it finds them quick. The only thing is I want to create an advanced search using the javascript. I have placed an example at my host. Please look at this for me and tell me why it's not working. MY ADVANCED SEARCH (http://ttsmerchandise.com/searchexample.htm). The only part of search engine that is working is additional keywords, everything else on there is just ignored. Some one please view my source and tell me what I am doing wrong.


Thank you!