• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How would you code a "search" bar on homepage?

 
Arun Singh Raaj
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume there is an application, it has a master search bar that searches the inputted text through all the pages and displays the matching resulting pages.
I want to know what logic would you write to implement this?
Can you just give me an idea about it?


Your help will be much appreciated.

Screenshot-2018-4-14-Children-s-Hospital-Los-Angeles-Pediatric-Hospital-Treating-Children-in-Southern-California-CHLA(2).png
[Thumbnail for Screenshot-2018-4-14-Children-s-Hospital-Los-Angeles-Pediatric-Hospital-Treating-Children-in-Southern-California-CHLA(2).png]
Search bar
Screenshot-2018-4-14-Search-Appointment.png
[Thumbnail for Screenshot-2018-4-14-Search-Appointment.png]
Results
 
Tim Holloway
Bartender
Posts: 20834
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I normally code the search controls in a separate form of their own, attached to their own code. That way I can re-use it independently on different pages.

It's good to note also that although web browsers are annoyingly "mousey" there is a standard of sorts for certain shortcut keys and one of them is for a search function. So it's nice to have the HTML coded to use it.

Almost forgot to mention: You CANNOT nest HTML forms, so if you code an independent search form (formlet), it cannot be included in the main form or it will not work. A side-effect of this is that since only data attached to the form being submitted is sent to the host, whatever data was in the other form(s) on the page is unaffected.
 
Arun Singh Raaj
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
Actually I want to know the "logic" for search operation.
 
Tim Holloway
Bartender
Posts: 20834
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Arun Singh Raaj wrote:Thanks!
Actually I want to know the "logic" for search operation.



That depends on what you want to search and how. It could be as simple as a servlet doing a database lookup all the way up to a Lucene full-text search.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!