• 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

Listing all the names starting with a perticular letter

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to populate a drop down box with a list of all the names from database starting with same a letter the user types in using javascript.

For ex when the user enters 'a' then the drop down box should have
'Abel'
'Abiba'
'Acacia'
'Asair'

Next when the user enters 'ab', the list should only show names starting with 'ab' ie,

'Abel'
'Abiba'

How do I do that?
Thanks
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://codingforums.com/showthread.php?t=9865
 
James Workmen
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric. Instead of hard coding the values in the HTML file, I would like to query the database for the names. I am using the struts framework
and what is the best way to do it. I mean, should I hit the database every time the user enter each character or... I am not sure what's the best way.. Can anyone suggest please.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way to look at it is like this, each time you hit the database the page has to reload, meaning there will be a big lag time each time you type a letter. My 2 Cents: It will be better to have all of the names listed, plus it is cutting on bandwidth/memory on the server.
 
James Workmen
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric. One last question, if my database is huge, lets say I have 10,000 names, performance wise is it still a good to get all the names in one go or is there any other alternative...

Thanks
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are going to have to test it out and see how it works, 10,000 names is a lot of inforamtion that has to be added to the page!

Hopefully someone else might propose somethig to you!
 
James Workmen
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No no, there are 10,000 names in the database, but I only have to access the names starting with the letter the user enters.
But lets say I only have 100 names in the database, I guess I can acces them all in one go and send it over to the JSP and then sort through using the JavaScript to populate the names stating with a perticular letter, Right?
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic