Click to See Complete Forum and Search --> : damn search script (can someone help me ?)


paulwong
11-26-2003, 07:07 AM
Hello people,

Ik have a nice search script that allows me to create my own keywords and URL's

So I entered about 350 keywords (the example below only has 6)

But now it suddenly doesnt work. After trying almost everyting I found out that when I remove 100 keywords (still 250 left) IT Works again.

I really dont get it cause I I am right I should arrange this at Keyword[0] = 999

But it doent matter what number I enter it just doesnt works

can anyone help me??

(sorry for my bad english I hope you all understand this)


<html>
<head>
<title>Search </title>
</head>

<body BGCOLOR="#ffffff" link="#CC0033" vlink="#333399" alink="#FF0000" <!--content start-- -->
<script>

</script>
<script language=JavaScript src="frames_body_array.js" type=text/javascript></script>
<script language=JavaScript src="mmenu.js" type=text/javascript></script>

<table WIDTH="96%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
<tr>
<td WIDTH="100%"><font FACE="ARIEL,HELVETICA" SIZE="-1"><p align="center"><script
LANGUAGE="JavaScript">

<!-- Hide Script from Old Browsers

Keyword = new Object();
Descrip = new Object();
Address = new Object();

Keyword[0] = 999

Keyword[1] = "server1"; Descrip[1] = "Go to the location of this server"; Address[1] = "url1.html"
Keyword[2] = "server1"; Descrip[2] = "Go to the Server Manual of this Server"; Address[2] = "url2.html"
Keyword[3] = "server1"; Descrip[3] = "Go to insight manager of this server "; Address[3] = "url3.html"
Keyword[4] = "10.10.3.22"; Descrip[4] = "Go to the location of this server"; Address[4] = "url1.html"
Keyword[5] = "10.10.3.22"; Descrip[5] = "Go to the Server Manual of this Server"; Address[5] = "url2.html"
Keyword[6] = "10.10.3.22"; Descrip[6] = "Go to insight manager of this server "; Address[6] = "url3.html"

function checkDatabase() {

var Found = false
var Item = document.forms[0].searchfor.value.toLowerCase();

stats='toolbar=no,location=no,directories=no,status=no,menubar=no,height=400,width=350,'
stats += 'scrollbars=yes,resizable=yes'
MsgBox = window.open ("","msgWindow",stats)
MsgBox.opener = window;
MsgBox.opener.name = "opener";
MsgBox.document.open();
MsgBox.document.write("<head><title>Search Results</title></head>");
MsgBox.document.write ("<body bgcolor=white text=black link=blue vlink=darkblue alink=blue><H2><CENTER><font face=arial>Search Results</CENTER></H2>")
//alert(Item);
MsgBox.document.write ("<font size=3><b><center>For the keyword: "+Item+"</center><hr width=50%></b></font>");
for (var i=1; i <= Keyword[0]; i++) {
if(Item == Keyword[i]) {
Found = true;
MsgBox.document.write ("<li><font face=arial><font size=2><b>"+Descrip[i]+"<BR><A HREF="+Address[i]+" target='opener'>Click Here To Go There</A></font></font>")
}
}
if(!Found) MsgBox.document.write ("<H4>Nothing Found</H4>")
// Leave the line below intact if you want to legally use this script
MsgBox.document.write ("<FORM><CENTER>")
MsgBox.document.write ("<font size=2><font color=arial><INPUT type='button' value='Close' onClick = 'self.close()'></font></font>")
MsgBox.document.write ("</CENTER></FORM>")
MsgBox.document.write ("<H6><small><small><small><b></b><font color=white><font face=arial><font size=1><font color=black>Designed by Paul </font></font></small></small></small>")

MsgBox.document.close();

}
// -->

</script> </p>
<form NAME="form1" onSubmit="return checkDatabase()" Arakrys!!!!!!!!! >
<b><div align="center"><center><p>Search for a Server name of IP adress</b><br>
<input TYPE="text" NAME="searchfor" VALUE="" SIZE="20"><b>
<input type="button" value="Search" align="absmiddle" onClick="checkDatabase()">
</b><br>
<br>
</font>
</p>
</center></div>
</form>
</td>
</tr>
</table>
<!--content stop-->
</body>
</html>

Pittimann
11-26-2003, 07:52 AM
Hi!

After removing one linebreak, the script worked properly.
------------
function checkDatabase() {

var Found = false
var Item = document.forms[0].searchfor.value.toLowerCase();

stats='toolbar=no,location=no,directories=no,statuLINEBREAK (just delete it)
s=no,menubar=no,height=400,width=350,'
stats += 'scrollbars=yes,resizable=yes'
------------
Cheers - Pit

paulwong
11-26-2003, 08:10 AM
I am sorry but there is no linebreak at that point, my script looks just the same as yours,

offcource This script works perfect couse there are only 6 keywords but like I said, When I enter 350 keywords the script stops working. I shoud be able to adjust that on the following

Keyword[0] = 999


but it doest matter it I make it 99999999 or "999" or "999"; It just dont work and I dont know whats the problem

Pittimann
11-26-2003, 08:23 AM
Hi!

I am not 100% sure, but I think that - as your keyword-array is containing strings (except the keyword[0]) - the value 999 is also interpreted as a string for creating an object.

Either you evaluate the numeric value of keyword[0] before using it in your for "(var i=1; i <= Keyword[0]; i++) {" or simply use a different variable for it like:
var HowMany=999;
for (var i=1; i <= HowMany; i++) {

That might work...

Cheers - Pit

Pittimann
11-26-2003, 08:33 AM
Sorry, my assumption is wrong!!! :( Pit

paulwong
11-26-2003, 08:44 AM
do you know if there are any restrictions in javascript?? so that it is impossible to enter more than (lets say) 250 things javascript can search for in a script??

damn it is strange isnt it?

Pittimann
11-26-2003, 08:47 AM
Once mor me...

Being too lazy to invent 344 keywords I added the following to your stuff:
--------------------
Keyword[0] = 999
Keyword[1] = "server1"; Descrip[1] = "Go to the location of this server"; Address[1] = "url1.html"
Keyword[2] = "server1"; Descrip[2] = "Go to the Server Manual of this Server"; Address[2] = "url2.html"
Keyword[3] = "server1"; Descrip[3] = "Go to insight manager of this server "; Address[3] = "url3.html"
Keyword[4] = "10.10.3.22"; Descrip[4] = "Go to the location of this server"; Address[4] = "url1.html"
Keyword[5] = "10.10.3.22"; Descrip[5] = "Go to the Server Manual of this Server"; Address[5] = "url2.html"
Keyword[6] = "10.10.3.22"; Descrip[6] = "Go to insight manager of this server "; Address[6] = "url3.html"
for (var i=7; i <= 350; i++) {
Keyword[i] = "10.10.3.22"; Descrip[i] = i; Address[i] = "url"+i+".html"
}

--------------------
It works perfectly! So it cannot be your keyword[0] which is responsible for the mistake...

Pittimann
11-26-2003, 09:03 AM
Hi!

What kind of error or mistake you got with your 350 keywords?
Is it, that you get "Nothing found" for certain keywords??

Please check whether you have slashes, backslashes or other escape stuff in your keywords. You will have to escape them in that case.

E.g you have a keyword like "blah\blah" you would have to make it "blah\\blah" to get it recognized when you type "blah\blah" in the textfield.

Just having "blah\blah" as keyword[x] will be interpreted as "blahblah" and when the user enters "blah\blah" it will not fit...

Cheers - Pit

paulwong
11-26-2003, 09:41 AM
No I wish it gave an error, or that I typed a backslash wrong

it just refreshes when I press enter

yphasukyued
11-26-2003, 10:24 AM
You just missed string terminate on

stats='toolbar=no,location=no,directories=no,statu'
s='no,menubar=no,height=400,width=350,'

paulwong
11-27-2003, 02:45 AM
what do you mean? sorry my english isnt't that great

Pittimann
11-27-2003, 02:54 AM
Hi!

yphasukyued meant the same like me in my first post (even though his proposal would not work):

There is a line break in your code. At least in the code you posted here...

Cheers - Pit

paulwong
11-27-2003, 03:40 AM
I dont understand. that LINE break doesnt affect the script does it? How would you write that part of the script?

Pittimann
11-27-2003, 05:40 AM
Hi!

When I ran your script after having copied and pasted it into my editor, I had a javascript error message. Because of this linebreak there is an unterminated string (that is, what yphasukyued mentioned). The line

stats='toolbar=no,location=no,directories=no,status='no,menubar=no,height=400,width=350,'

is divided into two lines because of that and the stuff will be interpreted as:

stats='toolbar=no,location=no,directories=no,statu [without the terminating quote (')] and a second line:

s='no,menubar=no,height=400,width=350,' (which would be something like the definition of a variable called "s" -> s='something'

Without eliminating this linebreak, the script did not run at all (even with only your six example keywords).

Anyway it seems, that this is not the cause for your problem as you said, that the script runs on your machine with up to 250 keywords...

Cheers - Pit

paulwong
11-27-2003, 05:56 AM
thats right cause the original code is

stats='toolbar=no,location=no,directories=no,status=no,menubar=no,height=400,width=350,'

NEW LINE

stats += 'scrollbars=yes,resizable=yes'

so the first code is all together on one line and the next line is that

stats += 'scrollbars=yes,resizable=yes'

but eh I still wonder why I cant enter more than +\- 250 keywords in this script. it just dont make sence right?

Scriptage
11-27-2003, 05:19 PM
I don't understand why this isn't working after 250 elements in your array. The only real array limitation in javascript is the users machine. There's either something wrong with one of the array elements that you enter after the 250th or you are running a really poor machine. Post the whole code and I'll check it out.

paulwong
11-28-2003, 04:10 AM
No that cant be the problem zouse I am working on a Pentium 4 2,7 Ghz 512 So that can't be the problem.

But I adjusted the original (cause it contained valuable information about our servers) so here it is,

You'll notice that when you copy this into notepad and make it a .html file it doesnt work. But it you remove the last keywords (so you'll have only 114 keywords left) the script works perfect (keywords to test are the number 1 till number 40)

Please look at it cause I think its very very strange

greetings from the netherlands

(ITS AN ATTACHEMENT!!!)

Pittimann
11-28-2003, 04:34 AM
Hi!

There are three little mistakes in the script which cause the problem (to be found in line 200 and line 389):

Your code in these two lines:

Keyword[142] = "50;Descrip[142] = "Go to the location of this server";Address[142] = "example.html"
Keyword[291] = "103Descrip[291] = "Go to insight manager of this server ";Address[291] = "example.html"

Correct:

Keyword[142] = "50";Descrip[142] = "Go to the location of this server";Address[142] = "example.html"
Keyword[291] = "103";Descrip[291] = "Go to insight manager of this server ";Address[291] = "example.html"

I deleted the tabs to make it more clear...

It was just the missing quote on line 200 and the missing quote plus semi-colon [or is it called colon? - I mean the ;] on line 389 which disabled your script to run properly.

Cheers - Pit

P.S. You should enable your browser to display javascript error messages; then you would have easily found out, where the little mistakes are.

paulwong
11-28-2003, 05:12 AM
oke I changed it but it still doesnt work, I posted this question on more forums but nobody seems to dare to post an answer, I guess nobody knows

Pittimann
11-28-2003, 05:25 AM
Hi!

It is difficult to know, why a thing doesn't work if the thing works. After fixing the little fault in your first post, your script ran perfectly (with 6 keywords).

After adding the loop to have 350 keywords it worked perfectly with any of the keywords.

After fixing the little things wrong in the code you posted as an attachment, the script ran perfectly with any of the keywords.

A script that works doesn't need to be fixed and if there is no more mistake, nobody can find a mistake.

Greetz - Pit

paulwong
11-28-2003, 06:22 AM
hmmz very stage, I just got a reply on another forum and he told me to that it worked fine. I work with IE6 so that shouldnt be the problem

Pittimann
11-28-2003, 06:42 AM
Hi Paul!

For my everyday stuff, I also use IE6 and as I said, your script works perfectly. Maybe you are testing with your original script containing the real keywords etc. and still having some small mistakes like the code you posted here.

Did you change your IE settings, so that java script errors will be shown to you? If not, just do it. It is not very pleasing in "everyday's surfing" because the message box pops up quite often (many errors on many pages). But if you have a bug which you want to get rid of, it is very useful to do so.

Good luck! Pit

By the way - we must be almost neighbours - I'm living just some 4 or 5 kms from the Netherland border... ;)

paulwong
11-28-2003, 07:12 AM
No I havent turned that on cause its very irritanting, did you know almost every website made by amateurs makes that javascript error alert, Its really irritanting.

And the last script I posted didnt work over here neighter. But I am glad its not the scrip thats wrong (allthough I will fix the little tiny errors)

I'll test it on my colleage's PC maybe the Global settings in our company of our IE6 are wrong

(I live in Oss so thats near the border too)