SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MORE Javascript >>

    hello,
    can someone examine this in NS 6, it doesnt appear to be working, also when i press the enter button or return on my keyboard it doesnt go either in either browser,, any ideas?

    Code:
    title = new Object();
    desc = new Object();
    links= new Object();
    matched= new Object();
    keywords= new Object();
    found= new Object();
    var temp=0;
    // actual location or the item to be searched // description of he location
    // actual link
    // percentage match found
    // keywords as parsed from the input 
    // # of titles present in the database 
    title[0]=14
    //no of keywords after parsing
    keywords[0]=0
    //no of  matches found.
    found[0]=0
    
    <!-- Begin List of Searchable Items -->
    
    <!--put the list of the links and descriptions here!!-->
    
    title[1]="esoteric sign supply"
    desc[1]="paint"
    links[1]="http://www.esotericsignsupply.com"
    matched[1]=0
    
    title[2]="gluechipping"
    desc[2]="gluechipping"
    links[2]="http://www.esotericsignsupply.com/gluechipping"
    matched[2]=0
    
    title[3]="paint,oneshot"
    desc[3]="paint,oneshot"
    links[3]="http://www.esotericsignsupply.com/paint"
    matched[3]=0
    
    title[4]="event handler onClick onLoad onMouseover onMouseout onUnload"
    desc[4]="Understanding Event Handlers in JavaScript"
    links[4]="http://www.javascriptkit.com/event.htm"
    matched[4]=0
    
    
    title[5]="object model tree accessing forms "
    desc[5]="Accessing and Validating Forms Using JavaScript (Part 1 of 2)"
    links[5]="http://www.javascriptkit.com/form1.htm"
    matched[5]=0
    
    title[6]="form validation onBlur onSubmit"
    desc[6]="Accessing and Validating Forms Using JavaScript (Part 2 of 2)"
    links[6]="http://www.javascriptkit.com/form2.htm"
    matched[6]=0
    
    
    
    title[7]="date object write html setTimeout function"
    desc[7]="Creating Time Dependent Scripts using JavaScript (Part 1 of 2)"
    links[7]="http://www.javascriptkit.com/time1.htm"
    matched[7]=0
    
    
    title[8]="live clock watermark"
    desc[8]="Creating Time Dependent Scripts using JavaScript (Part 2 of 2)"
    links[8]="http://www.javascriptkit.com/time2.htm"
    matched[8]=0
    
    
    title[9]="image preload rollover effect filter"
    desc[9]="Images and JavaScript- Apples and Apples (Part 1 of 2)"
    links[9]="http://www.javascriptkit.com/image1.htm"
    matched[9]=0
    
    
    title[10]="rollover effect"
    desc[10]="Images and JavaScript- Apples and Apples (Part 2 of 2)"
    links[10]="http://www.javascriptkit.com/image2.htm"
    matched[10]=0
    
    title[11]="new window open secondary reload close toolbar menubar status bar "
    desc[11]="Windows and JavaScript"
    links[11]="http://www.javascriptkit.com/window.htm"
    matched[11]=0
    
    title[12]="frames access object multiple"
    desc[12]="Loading Two frames with one link."
    links[12]="http://www.javascriptkit.com/twoframes.htm"
    matched[12]=0
    
    title[13]="selection list options array text vale"
    desc[13]="I'll hava a double combo please (Part 1 of 2)"
    links[13]="http://www.javascriptkit.com/combos1.htm"
    matched[13]=0
    
    title[14]="combo link box jump"
    desc[14]="I'll hava a double combo please (Part 2 of 2)"
    links[14]="http://www.javascriptkit.com/combos2.htm"
    matched[14]=0
    
    
    <!-- End list of Searchable items -->
    
    function search(){
    // get the input from the input by the user and strip it into keywords //
    var skeyword=document.searchengine.keywords.value.toLowerCase();
    
     var check=1;
    var pos=0;
    var i=0;
    var j=0;
    var  itemp=0;
    var config='';
    
    while (true)
    {
    if (skeyword.indexOf("+") == -1 )
    {
    keywords[check]=skeyword;
    
    break;
    }
    pos=skeyword.indexOf("+");
    if (skeyword !="+")     
    {
    keywords[check]=skeyword.substring(0,pos); check++;
    }
    else
    {
    check--;
    break;
    }
    skeyword=skeyword.substring(pos+1, skeyword.length);  
      if (skeyword.length ==0)
    {
    check--;
    break;
    }
    
    }
    // the keywords have been put in keywords object.
     keywords[0]=check;
    //alert(check);
    // matching and storing the matches in matched 
    for ( i=1; i<=keywords[0];i++)
    
    {
    for (j=1;j<=title[0];j++)
    
    {
    if (title[j].toLowerCase().indexOf(keywords[i]) > -1 )
    {
    matched[j]++;
    }
    }       
    }
    // putting all the indexes of the matched records  in found
    
    for (i=1;i<=title[0];i++)
    
    {
    if (matched[i] > 0 )
    {
    found[0]++;
    // increment the found  
    found[found[0]]=i;
    
    }       
    }
    //alert("found 0 " +  found[0]);
    // sort the list as per max percentage of matches
    
    
    for (i=1;i<=found[0]-1;i++)
    
    {
    for(j=i+1;j<=found[0];j++)
    
    {
    if ( matched[found[i]]< matched[found[j]] )
    {
    temp= found[j];
    
    found[j]=found[i];
    
    found[i]=temp;
    
    }
    }
    }
    
    
    
    
    
    
    for (i=1;  i<=keywords[0];i++)
    
    
    
    {
    
    if (found[0]==0)
    {
    
    
    
    }
    else
    
    
    
    for (i=1; i<=found[0];i++)
    
    {
    
     itemp=found[i];
    
    output=window.open(links[itemp]);
    temp= (matched[itemp]/keywords[0])*100 
    
    matched[itemp]=0
    } 
    found[0]=0;
    
    }
    
    
    }
    
    
    </script>
    and the form itself

    Code:
    <FORM name=searchengine><CENTER><input maxlength=40
    name=keywords size="15" value="search"> <input type=button value="GO" name=go
    onClick=search()><BR></CENTER></FORM>
    thanks for any help,

    -r
    Last edited by rkosmic1; May 26, 2002 at 00:47.
    turn your site into a lead generating and money making machine.
    WE CAN SHOW YOU HOW
    Logical Media Web Design

  2. #2
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any chance of a URL where we can test the above code out?

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    turn your site into a lead generating and money making machine.
    WE CAN SHOW YOU HOW
    Logical Media Web Design

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone else? i still need your help,,=)
    Last edited by rkosmic1; Jun 1, 2002 at 23:40.
    turn your site into a lead generating and money making machine.
    WE CAN SHOW YOU HOW
    Logical Media Web Design

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the problem is here

    PHP Code:
    pos=skeyword.indexOf("+");
    if (
    skeyword !="+")     
    {
    keywords[check]=skeyword.substring(0,pos); check++;
    }
    else
    {
    check--;
    break;
    }
    skeyword=skeyword.substring(pos+1skeyword.length);  
      if (
    skeyword.length ==0)
    {
    check--; 
    with substring

    i'm not the person to really ask about crossbrowserbility but

    try using substr instead.

    http://developer.netscape.com/suppor...cript.html#2-5

  6. #6
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks i will give that a try
    turn your site into a lead generating and money making machine.
    WE CAN SHOW YOU HOW
    Logical Media Web Design


Bookmarks

Posting Permissions

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