Click to See Complete Forum and Search --> : Does Anyone Know Where I can Find


tam42025
04-23-2003, 01:40 PM
A tutorial that explains step by step how to create a search engine for your site. I keep trying these scripts and I can't get it to work. I also have learned how to use javascript and I understand everything about the scripts I try to manipulate with the exception of all this math. The problem is the scripts you get aren't very informational. You look at it and there is all these codes that you don't understand. Does anyone know of a tutorial that explains step by step how to create a search. Maybe if I can find one, I can begin learning how to get the search to do what I want.

tam42025
04-23-2003, 01:45 PM
what I want to do is create an advanced search engine for my site and I can't find any scripts or tutorials that show you how to do it. It's always the basic search script.

khalidali63
04-23-2003, 01:46 PM
Do you mean a search utility for your site that will do search within your web pages???

tam42025
04-23-2003, 01:54 PM
yes, I want to be able to search my own pages. I used a script that was wonderful for a basic search but what if you want your search engine to do more. I see so many websites who have advanced search, even this one, and I just don't even know where to begin on how to do something like that. I have tried to use the little knowledge I have on javascript to manipulate other codes into doing it but they never work. I am so frustrated because I really want this option for my viewers and after an entire month, I am still no closer to it then when I started. If you know of some tutorials that specifically shows you how to create an advanced search option, I would appreciate it.

khalidali63
04-23-2003, 02:04 PM
Ok the idea of having a search engine could be implemented as below, remind you there could be multiple approaches to it depending upon the person.

1. You have all the webpages ready on your site.
2. create a list of keywords for those individual webpages,e.g a webpage that contains info about all programming languages,it might have keywords such as "programming","C/C++","Java","Ada","SmallTalk","JavaScript","development" and so on.
once you have all the relative keywords layed out on a paper,then comes to organise them in a way that they can be accessed quickly(Arrays????)..
3. Now you can create an array which have all the keywords for all the pages..may be something like this

var keyWords = new Array();
keyWords[0] = new Array("programming","C/C++","Java","Ada","SmallTalk","JavaScript","development");

4. now what you need to do is get user input and compare it with the entries in the array
in the above array you have a multidimensional array which has a whole new array at index = 0;
where main array index=webpage
and second dimention array will hold keywords for that page
something liket his
keyWords[0] = this will point to a webpage that programmig related stuff
to loop through you will have to keep this distinction in mind

for(var n=0;n<keyWords.length;n++){//web page
for(varx=0;x<keyWords[n].length;x++){//keywords for this page
//comparison here
}
}

once you have all the entries found

then you can write the results to a window or the same page..
I hope this helps a bit..

tam42025
04-23-2003, 02:15 PM
It helps a lot. Thank you! But what confuses me more is how do I get that code to recognize each individual input that is selected from the form. For instance if I had a dropdown menu that gives them the choic of selecting from option 1 option 2 and option 3 and then I have another input that asks them to select from a price range starting at option 1 option 2 option 3 and ending at option 1 option 2 and option 3. How do I get the code first to understand that when the viewer makes these selections and hits submit to combine these queries together.

That's the part that I am really struggling with.

khalidali63
04-23-2003, 02:19 PM
Well that can be achieved in multiple ways as well depending upon your validation rules.
.you can make it so that if a value from first is checked and they try to click the submit,the search won't start unless the compplete the query,which is selecting from whatever fields you deem are necessary.

tam42025
04-23-2003, 02:43 PM
First I want to thank you for taking the time to explain this to me. This is what I thought I could do. I thought I could just name my selections give my options values and name my inputs and be able to call those names and values from the javascript code.

For instance <form name="example1"><select name=work>
<option value="">whatever</option>
<option value="">whatever2</option>
</select>
<input type=text name=srchval value="">

I thought in an example like that to call it in my code I would just have to enter this

document.example1.work.options[] + document.example1.srchval.value

I know this probably looks stupid, lol, but in my mind I thought I could combine the two with a + and that would make my code search for both queries. It didn't work.

I don't want them to have to select everything in order to perform a search. I just want them to be able to search what they want to perform a search and that search will be limited to only what they select. If that makes sense.

This link will take you to a page with an example of what I am trying to do Search Example (http://ttsmerchandise.com/searchexample.htm) As you can see the only thing that works is the keywords and that's because it contains the input that originally came with the javascript code.

khalidali63
04-23-2003, 02:47 PM
Originally posted by tam42025

document.example1.work.options[] .........

to get a value selected by a user in a listbox you need to point to the option that is selected..you are close though.Here like this

document.example1.work.options[document.example1.work.selectedIndex].text

And I'll take a look and see how much time I can put away for this.. :D

khalidali63
04-23-2003, 02:54 PM
Can you point me to the link where you have th original script....

tam42025
04-23-2003, 02:58 PM
what about this:

For instance <form name="example1"><select name=work>
<option value="0">whatever</option>
<option value="1">whatever2</option>
</select>
<input type=text name=srchval value="">

document.example1.work.options[1].text

Or am I still off!!!!! lol

tam42025
04-23-2003, 03:00 PM
Sure it's Original Script (http://javascript.internet.com/miscellaneous/site-search.html)

khalidali63
04-23-2003, 03:01 PM
it should work,but this does not necessary mean that you have selected the secons option...use the code I posted above..:p