www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: damn search script (can someone help me ?)

  1. #1
    Join Date
    Oct 2003
    Posts
    14

    damn search script (can someone help me ?)

    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>

  2. #2
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    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

  3. #3
    Join Date
    Oct 2003
    Posts
    14
    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

  4. #4
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    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

  5. #5
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    Sorry, my assumption is wrong!!! Pit

  6. #6
    Join Date
    Oct 2003
    Posts
    14
    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?

  7. #7
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    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...

  8. #8
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    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

  9. #9
    Join Date
    Oct 2003
    Posts
    14
    No I wish it gave an error, or that I typed a backslash wrong

    it just refreshes when I press enter

  10. #10
    Join Date
    Nov 2003
    Posts
    40
    You just missed string terminate on

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

  11. #11
    Join Date
    Oct 2003
    Posts
    14
    what do you mean? sorry my english isnt't that great

  12. #12
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    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

  13. #13
    Join Date
    Oct 2003
    Posts
    14
    I dont understand. that LINE break doesnt affect the script does it? How would you write that part of the script?

  14. #14
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    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

  15. #15
    Join Date
    Oct 2003
    Posts
    14
    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?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles