View Full Version : Form validation

02-26-2007, 11:29 AM

I am new to javascript so if i ask a non-javascript question please excuse me for that.

Can someone give me example on how to create drop down list
like travelsupermarket.com. When searching for flight destinations, upon entering the first three letters you get an auto list to select the most appropriate.

Basically I need something similar to make sure that the user enters
correct account number (retrieved from mysql) on the form.

I have used php/mysql.

I hope i have made sense.

02-26-2007, 03:33 PM
Editable Type-ahead Combo script in my sig might be the one you're looking for.

02-26-2007, 04:31 PM
thanks for the reply but its not what im looking for. if you go to travelsupermarket.com
and type first few letters of destination in 'flying to' textbox you will know what i mean. my try typing just 'dub' and you will get the list below to choose from.

02-26-2007, 08:13 PM
Having looked at the page source of that site I have to say that to accomplish such a drop-down list is no small feat. The developers of the site use Ajax technology and a continuosly running function that get called on the focus event to bring the search results from the server. Not for the faint of heart. I mean it will take a lot of work.

03-01-2007, 10:31 AM
Thank for the reply. Is there are a way to do something similar using javascript. Basically I want to make sure that the user only enter account numbers exists in mysql database. Any highlight on alternative solution(s) would be greatly appreciated.

Thanks again

03-02-2007, 04:32 PM
An alternative solution would be obtain account numbers from the database first and create an array of account numbers in client-side JavaScript when the page is first loaded. Then you could check user-typed numbers against that array without having to go the server. Naturally, this exposes account numbers to anyone willing to view the page source so it might not be suitable.
Ajax is the best solution in this situation.