• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 240
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 240
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
Actually I want to know the "logic" for search operation.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic