Solved

Search tool

Posted on 2001-09-13
8
173 Views
Last Modified: 2010-04-09
I know hot to add a search tool on my site. My problem is that when an entry is found, I'd like to have the choice of continuing the search in the page for more entries of the same name.

Thanks !
0
Comment
Question by:MNY
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6479450
You need to show us the code you are using for your search tool.
0
 

Author Comment

by:MNY
ID: 6479467
Ok here it is:

<script language="JavaScript">

var NS4 = (document.layers);    // Which browser?
var IE4 = (document.all);

var win = window;    // window to search.
var n   = 0;

function findInPage(str) {

  var txt, i, found;

  if (str == "")
    return false;

  // Find next occurance of the given string on the page, wrap around to the
  // start of the page if necessary.

  if (NS4) {

    // Look for match starting at the current point. If not found, rewind
    // back to the first match.

    if (!win.find(str))
      while(win.find(str, false, true))
        n++;
    else
      n++;

    // If not found in either direction, give message.

    if (n == 0)
      alert("Not found.");
  }

  if (IE4) {
    txt = win.document.body.createTextRange();

    // Find the nth match from the top of the page.

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

    // If found, mark it and scroll it into view.

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

    // Otherwise, start over at the top of the page and find first match.

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

      // Not found anywhere, give message.

      else
        alert("Not found.");
    }
  }

  return false;
}

</script>
</body>

</html>
<p>&nbsp;<form name="search" onSubmit="return findInPage(this.string.value);">
<p align="center">
<font size=3><input name="string" type="text" size=15 onChange="n = 0;"></font><font face="Arial" size="4"><input type="submit" value="Search Page">

</font>
</form></p>
0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6479550
Ok...this is just a suggestion, but I don't think you want to use JavaScript here unless it is a last resort.

If I understand the general idea, you are trying to do a site about the horrific happenings in the USA.  You are going to have a very general audience.   Also, you are going to be using server side scripting for the posting part.....so why not use server side scripting for the search too?  It would be less reliant on the user having scripting enabled on their browser.

Just a suggestion.  
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MNY
ID: 6480207
I just want to be able to continue searching after it found one instance...like Microsoft's
0
 
LVL 7

Accepted Solution

by:
ClassyLinks earned 100 total points
ID: 6480425
May I suggest this script if you are sticking with Javascript.

http://www.infohiway.com/javascript/search/wildcard.htm

It will display all instances of a word and let the user choose which to go to.
0
 

Author Comment

by:MNY
ID: 6480451
anynews on my other question regarding an entry counter?
0
 
LVL 7

Expert Comment

by:ClassyLinks
ID: 6480460
Thanks for the A.


I thought you closed out your other question.....aren't you going to implement it with the excel db?
0
 

Author Comment

by:MNY
ID: 6480468
I will stick with the ASP page. I'm not going to pick a database... I just need to know if there's such a thing?
(entry counter)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question