Hi all,
I am completely new to Ajax, I need to create Telephone directory.
Telephone numbers and phone are in database, I designed UI like two text boxes for search by name search by number. I have one div which displays the search results. It is a J2ee application, I am getting the results when i enter the number or name completely then submit the button.

Now I need to re design like,the result should appear when I Type partial information.It should like when I type letter A in name text box it should displays the list of names which starts with the letter A .How can I do that.
could any one help me
Thanks in advance

Recommended Answers

All 5 Replies

"Like two text boxes" or genuinely two text boxes?

two separate text boxes

Member Avatar for stbuchok

Use the onkeypress event instead of using the submit button to grab your data. You may want to modify this though so that it only starts grabbing after "n" characters, then save the results in memory and iterate over those results rather than calling the web service again.

Example:
Do search for a phone number after the 3rd number is pressed.
Save the results from the 3rd key press into an array (or something else that you can search through)
On keypresses after the 3rd, search for results in the array rather than making another call to the database.

This will only be beneficial if you are not dealing with huge results. If you are, refine it to do it on the fourth or fifth key press.

This is my 2 two cents.

Yes I agree with Stbuchok's suggestion to make first contact with the server after 3 or so key presses.

The rest (client-side caching and refinement of results) can probably be handled by something I wrote earlier this year.

http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/375311
See the attachment to my post dated Aug 3rd.

Airshow

thanks Airshow and stbuchok

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.