# Create a search box to emulate CTRL + F



## snorkytheweasel (May 3, 2006)

I want to make it easy for the user to search the current page.

Rather than assume that users understand & can use the browser's built-in CTRL + F feature, I want to create a prominent (in the header portion of the dynamic content) search box that works like CTRL + F

Since the page is generated by a PHP/MySQL query, and since the results could return hundreds of lines, a nice/important feature would be the search box code's ability to find the next occurrence of the string as it is typed into the box (just like CTRL + F)

Surely there is some canned code to do this, but I haven't had any luck. A few years ago I wrote a plain-jane search box that used Google's API, but 

I can't find it on the Google site
I threw out all of the pages that contained that code
Back then, Google's code offered two choices: search the current domain or use a straight-up Google search of the universe as we know it. I want to limit the search to the current page ONLY (like CTRL + F)


----------



## TheRobatron (Oct 25, 2007)

Try DynamicDrive's search page code:
http://www.dynamicdrive.com/dynamicindex11/findpage.htm

There are loads of results for a Google search. The code, however doesn't appear to work in Firefox (or at least not Firefox 2).


----------



## snorkytheweasel (May 3, 2006)

THX. I found a script that works well enough.

Now to complicate matters:

The script works when embedded in the page's code. However, I'm racking my brains, and searching via google, and reading my books.... and I can't figure out how to call the same script when I've removed the script from my html and placed the js into its own file.

I do this quite routinely with php scripts, yet tweaking the javascript and the web page to make the "remote" script work eludes me. It must be a senior moment.

HELP!!


----------



## TheRobatron (Oct 25, 2007)

Have you tried ?


----------

