I have this very simple keyword script but I want to modify it a little bit. Here's the code:
<script language="Javascript">
//Declare variables.
var j = 0;
var LowerCaseKey;
var Keyword = new Array();
var KeyURL = new Array();
//This array is for the keywords.
Keyword[0] = "internet";
Keyword[1] = "javascript";
Keyword[2] = "discussions";
//This array is for the sites/pages associated with your keywords.
KeyURL[0] = "http://www.internet.com";
KeyURL[1] = "http://www.javascripts.com";
KeyURL[2] = "http://forums.webdeveloper.com";
//Check to see if keyword exists, and if it does, take them to that page.
function findKeyword()
{
for (j=0; j<=Keyword.length; j++)
{
LowerCaseKey = document.form.keyword.value.toLowerCase();
if (LowerCaseKey == Keyword[j])
window.location = KeyURL[j];
}
}
</script>
</head>
<body>
<form name="form">
Enter internet to visit internet.com, javascript to visit JavaScripts.com, or discussions to visit WebDeveloper Forums.<br><br>
Enter Keyword:*
<input type="text" name="keyword" size="15">*
<input type=button value="Go" onclick="findKeyword()">
</form>
Now, the top part (Which is the actual script and has the values for the keywords) i would like to have that in it's own file. Then I just want the form to go to it and see what it matches. This way, I can just put the form on all my pages and have it go to one set script to match keywords up. Do you get it? I'm new at this so if I'm not making myself clear please let me know. I'm sure this is very simple and I'm just overlooking something, but I tried a few ways and I could not get it to work, but then again Javascript isn't my thing.
Also, does anybody know how to put a Not Found page. So that way, if somebody enters a keyword that doesn't match, instead of it doing nothing, it can go to a specified page that says no keyword exists.
Thank you all so much!! I am very appreciative!
-Sam