I am working on making my own search that is very small, and uses only 1 page (no outside scripts). I don' tactually have to code for it, yet, but this is what is going to happen.
1. You type in a keyword into a text box. Let's say you type in 'guitar'
2. The text box's JavaScript looks up anything with the name 'guitar' in the page's content/title.
3. It displays the search results (using 'document.writeIn'). All pages with the word 'guitar' will show up like this ((in order from most relevant (in the title, for example) to least)):
Code:
Guitar TablatureTablature - Here you can find guitar tablature for some songs!
http://www.execulink.com/~kayes/physicsguy/web/tablature.shtml
Music
Here at the music section, you can find all the other music stuff!
http://www.execulink.com/~kayes/physicsguy/web/music.shtml
Home
Welcome to PGReviews! Here, we have guitar tablature, animations...
4. You can click any link to go to that page, and voila! Yu got yerself uh surch funkshun!
So far, here's the outline of what I have:
It's amazing. I don't know.
Who can help? THANKS if so!!!
Here's some technical stuff how it would work:
Code:
<script id="searchlookup" type="text/javascript">
var searchLookUp=new Array(3);
searchLookUp[0]="Page 1, it's keywords, description, blah blah blah";
searchLookUp[1]="Page 2, it's keywords, description, blah blah blah";
searchLookUp[2]="Page 3, it's keywords, description, blah blah blah";
</script>
<script type="text/javascript">
function welcome()
{
document.writeIn(" + document.forms["searchform"]["searchlookup"].value + ".htm*");
}
</script>
<script type="text/javascript">
if (search < 0)
{
document.write("No search results found. Try using a different keyword.");
}
else
{
document.write(" (search results) ");
}
</script>
<form name="searchformform" action="search.htm" onsubmit="welcome()" id="searchform">
<p>Search PGReviews!</p>
<input type="text" name="searchlookup" size="20" />
<input type="button" value="Search" onclick="welcome()" />
</form>
Or instead, this function:
Code:
<script type="text/javascript">
function welcome()
{
document.write(searchLookUp[0]);
}
</script>
(Except that the [0] would access to a keyword, with ANOTHER array!)
Now I KNOW that won't work. 'goto' isn't valid. But that's the idea.
searchlookup refers to a JavaScript file that looks at an array of all the pages, keywords, titles, and addresses.
Here's something that works, but it's sort of useless.
Code:
<script type="text/javascript">
var searchLookUp=new Array();
searchLookUp[0]="[Goes to Page 1]";
searchLookUp[1]="Page 2";
searchLookUp[2]="Page 3";
</script>
<script type="text/javascript">
function welcome()
{
document.write(searchLookUp[0]);
}
</script>
<input type="text" name="searchlookup" size="20" />
<input type="button" value="Search" onclick="welcome()" />
If you type '0' (without the quotes) into the text box, it displays Page 1. Getting there. You need to know the number of the age to get there, though.
I just don't get what's going on here, though. There is no [3], yet is displays it!
Code:
<script type="text/javascript">
<script type="text/javascript">
var searchLookUp=new Array(3);
searchLookUp[0]="[Goes to Page 1]";
searchLookUp[1]="Page 2";
searchLookUp[2]="Page 3";
</script>
<script type="text/javascript">
function welcome()
{
document.write("searchLookUp[" + document.forms["searchform"]["searchlookup"].value + "]");
}
</script>
<form name="searchform" onsubmit="welcome()" id="searchform">
<input type="text" name="searchlookup" size="20" />
<input type="button" value="Search" onclick="welcome()" />
</form>
I can completely remove the
searchLookUp[0]="[Goes to Page 1]";
searchLookUp[1]="Page 2";
searchLookUp[2]="Page 3";
and it still works! I don't get it! It just writes the name of the 'var', then the array number!
Actually, the whole array isn't used AT ALL! The 'searchLookUp' comes from the part after 'document.write'!! You could change it to 'hello world!' and it would say 'hello world!' with what you typed in!
AAAAAAHHHH!!!
What I need to do is make it:
If document = searchLookUp[0], document.write("Welcome to Page 1!");
If document = searchLookUp[2], document.write("Welcome to Page 2!");
and so on...
I need a database of all these. I could do it, but that wouldn't make it display a 'results' page, nor any working links, OR any actual content, or pages, or listings.........
I'm in so much confusion! AUGH!