Results 1 to 12 of 12
  1. #1
    Marketing Mistress Lectrickitty's Avatar
    Join Date
    June 15th, 2005
    Location
    Broken Bow, OK
    Posts
    336
    page search function question?
    I have a genealogy page that has over 1500 family names on a single page. Is there a way I can make a search engine at the top of the page where visitors can type in the name they are looking for and they will be taken to the line where that name resides. I don't want the search box to include any other pages, only that one page.

    Does anyone have or know of a code I can use to do this?

    Thanks,
    [color=blue]"Those who give up their freedom for a little security deserve neither freedom nor security" - Benjamin Franklin[/color]

  2. #2
    ABW Ambassador
    Join Date
    November 25th, 2005
    Posts
    639
    Page search function
    Lectrickitty,

    There is a nice little Javascript located here:
    http://www.javascript-page.com/pgsearch.html

    Hope you like it!

    CanadianDave

  3. #3
    Marketing Mistress Lectrickitty's Avatar
    Join Date
    June 15th, 2005
    Location
    Broken Bow, OK
    Posts
    336
    Thanks Dave, that's exactly what I was looking for.
    [color=blue]"Those who give up their freedom for a little security deserve neither freedom nor security" - Benjamin Franklin[/color]

  4. #4
    ABW Ambassador
    Join Date
    November 25th, 2005
    Posts
    639
    Glad to help!

  5. #5
    Marketing Mistress Lectrickitty's Avatar
    Join Date
    June 15th, 2005
    Location
    Broken Bow, OK
    Posts
    336
    I copied the code exactly and it doesn't work on my page. Any javascript guru's here want to take a look at the script and see if I need to make a change to get it working? I'm wondering if I should have made any small changes to customize it to my page...


    here's the script I used:

    <script language="Javascript">
    <!--
    // original content taken from Nic's JavaScript Page with permission
    // lack of these three lines will result in copyright infringment
    // made by: Nic's JavaScript Page - http://www.javascript-page.com
    var numtimes = 0;
    function findinpage(str) {
    if (str == "") return false;
    if (document.layers) {
    if (!window.find(str)) {
    while(window.find(str, false, true)) n++;
    }
    else numtimes++;
    if (numtimes == 0) alert("The word \""+ str +"\" was not found on this page.");
    }
    if (document.all) {
    var txt = window.document.body.createTextRange();
    var found = txt.findText(str);
    for (var i = 0; i <= numtimes && found != false; i++) {
    txt.moveStart("character", 1);
    txt.moveEnd("textedit");
    }
    if (found) {
    txt.moveStart("character", -1);
    txt.findText(str);
    txt.select();
    txt.scrollIntoView();
    numtimes++;
    }
    else {
    if (numtimes > 0) {
    numtimes = 0;
    findinpage(str);
    }
    else alert("The word \""+ str +"\" was not found on this page.");
    }
    return false;
    }
    }
    //-->
    </script>
    <form name="search">
    <font size="3"><input name="string" size="35" onchange="numtimes = 0;"></font>
    <input type="button" value="Find" onclick="return findInPage(document.search.string.value);">
    </form>
    [color=blue]"Those who give up their freedom for a little security deserve neither freedom nor security" - Benjamin Franklin[/color]

  6. #6
    ABW Ambassador
    Join Date
    November 25th, 2005
    Posts
    639
    Lectrickitty,

    Sorry about that - when I tested it, is didn't work either.
    The code below did work (it is an entire HTML page).

    CanadianDave


    <html><head><title>Javascript: Page Search</title>

    <body aLink=#aa0000 bgColor=#ffffff link=#aa0000 text=#000000 vLink=#aa0000>

    <script language="JavaScript">
    <!--
    // original content taken from Nic's JavaScript Page with permission
    // lack of these three lines will result in copyright infringment
    // made by: Nic's JavaScript Page - http://www.javascript-page.com

    var n = 0;

    function findInPage(str) {

    if (str == "") return false;

    if (document.layers) {

    if (!window.find(str)) {while(window.find(str, false, true)) n++;}
    else n++;

    if (n == 0) alert("The word \""+ str +"\" was not found on this page.");
    }

    if (document.all) {
    var txt = window.document.body.createTextRange();
    var found = txt.findText(str);

    for (var i = 0; i <= n && found != false; i++) {
    txt.moveStart("character", 1);
    txt.moveEnd("textedit");
    }

    if (found) {
    txt.moveStart("character", -1);
    txt.findText(str);
    txt.select();
    txt.scrollIntoView();
    n++;
    }

    else {
    if (n > 0) {
    n = 0;
    findInPage(str);
    }

    else alert("The word \""+ str +"\" was not found on this page.");
    }

    return false;
    }
    }

    //-->
    </script>

    <form name="search">
    <font size=3><input name="string" type="text" size=15 onChange="n = 0;"></font>
    <input type="button" value="Find" onclick="return findInPage(document.search.string.value);">
    </form>
    Now, at first glance, you may think this is a javascript search engine for your
    site. NO! This can only search for certain text strings within the page you are
    at. However, it is still a very helpfull script. This is great if you have a really
    long tutorial site or something similiar that is several pages long and want to
    give your users the ability to find what they want from the text really fast instead
    of having to look down 5+ pages of material. The source...<br>
    <font color=#0000aa><b></b></font>
    </body>
    </html>

  7. #7
    Marketing Mistress Lectrickitty's Avatar
    Join Date
    June 15th, 2005
    Location
    Broken Bow, OK
    Posts
    336
    Thanks Dave, Now I need to figure out what to do with it. I'll play with it and see if I can get it to work.
    Last edited by Lectrickitty; March 10th, 2006 at 05:30 PM.
    [color=blue]"Those who give up their freedom for a little security deserve neither freedom nor security" - Benjamin Franklin[/color]

  8. #8
    ABW Ambassador
    Join Date
    November 25th, 2005
    Posts
    639
    I would try carefully stripping away the HTML (and testing that the script still works) until you get it down to just the working script.

  9. #9
    Marketing Mistress Lectrickitty's Avatar
    Join Date
    June 15th, 2005
    Location
    Broken Bow, OK
    Posts
    336

    It works!!!




    Thank You!
    [color=blue]"Those who give up their freedom for a little security deserve neither freedom nor security" - Benjamin Franklin[/color]

  10. #10
    Marketing Mistress Lectrickitty's Avatar
    Join Date
    June 15th, 2005
    Location
    Broken Bow, OK
    Posts
    336
    One more question...

    The search goes 2 deep. If I search on the name John, it will find the 1st John, then click "find" again and it finds the 2nd John. If I click on "find" again, it stays on the second John and won't find the 3rd John.

    Do you know how I can get it to go on down the list and find all 15 John names?

    Sorry to be such a whinner, but I really would like to make it find all the occurances of the names, not only the first 2.

    Thanks again.
    [color=blue]"Those who give up their freedom for a little security deserve neither freedom nor security" - Benjamin Franklin[/color]

  11. #11
    ABW Ambassador
    Join Date
    November 25th, 2005
    Posts
    639
    I have e-mailed Nic to see if he can fix it... I will post as soon as I hear back.

  12. #12
    ABW Ambassador
    Join Date
    November 25th, 2005
    Posts
    639
    Sorry Lectrickitty,

    No word back yet...
    My JScript abilities are not up to fixing this - anyone else have an idea on how to make this script search beyond two results?

    CanadianDave

  13. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Search Function is Atrocious...
    By Convergence in forum Rakuten LinkShare - LS
    Replies: 3
    Last Post: October 14th, 2014, 03:44 PM
  2. Search Function
    By AdamlCasey in forum PopShops
    Replies: 7
    Last Post: January 19th, 2010, 10:40 AM
  3. Need Help with GoldenCan search function
    By slocum in forum GoldenCAN
    Replies: 1
    Last Post: March 13th, 2009, 03:26 PM
  4. Is the search function broken?
    By DHolland in forum ShareASale - SAS
    Replies: 0
    Last Post: February 6th, 2008, 12:59 PM
  5. The #@!%&* Search Function
    By Cedric in forum Rakuten LinkShare - LS
    Replies: 5
    Last Post: September 17th, 2002, 03:27 PM

Posting Permissions

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