-2

Is it possible to have a search field without a database?

I have a basic HTML and CSS website where on only one page I need a search box to search only that page (large page with lots of data), if possible to search the whole site would be great but only need one page now and don't want to use a database.

Have you seen this done or know if it is possible? I have seen search fields where you link to Google's database and you embed results on your site but that won't work.

j08691
  • 204,283
  • 31
  • 260
  • 272
BHCOM
  • 124
  • 1
  • 2
  • 11
  • Have a look at those threads: http://stackoverflow.com/questions/13799154/searching-the-text-on-website http://stackoverflow.com/questions/6207563/javascript-string-search-a-website – goodpixels Mar 09 '15 at 17:11

2 Answers2

1

Since you have only CSS and HTML code (and no PHP + MySQL) the only solution for you is to use JavaScript which runs on client side. You can use the window.find() function but it doesn't work on all browsers. See: Use Browser Search (Ctrl+F) through a button in website?

What you need is to tell the user to hit CTRL + F in order to use the browser's search module.

Community
  • 1
  • 1
valicu2000
  • 441
  • 5
  • 19
  • Thanks valicu2000. You pointed me in the right direction. I know this was a weird question but was needed for this project so thanks for your efforts. – BHCOM Mar 09 '15 at 23:30
1

FOUND IT...

It works on Firefox, Chrome, Safari, and even Opera. Don't care about IE.

http://www.javascripter.net/faq/searchin.htm

If you use, read the bottom. You will want to use an iframe for the HTML otherwise your search box searches the keyword in the actual box... which is kind of funny. Anyways thanks for the votes guys and sorry you couldn't be as cool as @valicu2000 who pointed me in the right direction to find this solution.

BHCOM
  • 124
  • 1
  • 2
  • 11