Current location: Hot Scripts Forums » General Web Coding » JavaScript » Need help with this keyword script - i'm sure it's simple!


Need help with this keyword script - i'm sure it's simple!

Reply
  #1 (permalink)  
Old 05-19-04, 03:40 PM
dudeman248 dudeman248 is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Need help with this keyword script - i'm sure it's simple!

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
Reply With Quote
  #2 (permalink)  
Old 05-19-04, 04:36 PM
Chris Hill Chris Hill is offline
Newbie Coder
 
Join Date: Mar 2004
Location: UK
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
I think it would be easier to use a drop down menu for what you want, and then use the onChange even handler instead of the onClick. At the moment, it seems to me that you want a kind of search page that will take you to a specific site if you type in the right string.

It would be far easier looking at the script to use a dop down menu.
__________________
<a href="http://www.WhiteHillStudios.co.uk/home.php" target="_blank">White Hill Studios</a> - driving down the cost of web design<br>
<a href="http://www.agscriptz.com" target="_blank">AG Scriptz ii: renaissance</a> - a new dawn or scripting
Reply With Quote
  #3 (permalink)  
Old 05-19-04, 05:11 PM
dudeman248 dudeman248 is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
That would be much simpler, but I hope on having a lot of pages in there and that would be too large of a menu. We are using this for a church page and we want to be able to put the keyword in the bulletin.

For example: To register for VBS, go to fbcgriffith.org keyword:vbs.

We use a drop down menu now and it's just got a few sites in there. Thanks!

-Sam
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
Looking for a simple script bumpdiggler Script Requests 0 02-26-04 11:54 AM
simple register script evolutiontheory The Lounge 0 01-27-04 01:00 PM
Need a simple php script jarod Script Requests 1 11-05-03 08:38 AM
Seeking for a simple photo gallery script... Sgrebs PHP 0 10-27-03 02:00 PM


All times are GMT -5. The time now is 02:20 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.