开发者

Form autofill if value exist in database using AJax

I have a form I need to auto fill it using Ajax and php. Suppose My unique field is mobile number. So when form appears firstly person has to fill mobile number. If mobile number exist in the database than all the rest field retrieve its value that is his name, email etc, making all the text fields disable.

my approach to this work is on blur effect I can send value through AJAX. but how call values in array. I have called only sin开发者_Go百科gle value through echo; but have not called array back from java script page.

Secondly I need jquery to fill all form with respective values and disable particular fields in form.

Please give me some more idea to make this approach better and provide some hint to implement it efficiently.


have you tried Autocomplete from JQuery UI?

http://jqueryui.com/demos/autocomplete/

it is very easy to use, it uses ajax and can be easly used with php. Tell if you will have any problems.


A simple way to do this is to separate your page into 2 forms. The first form will contain only the mobile number field, while the second form will not be initially visible. This way, the user will be forced to fill in his mobile phone before doing anything else.

Submitting the first form will trigger an ajax call to your php file which will check whether the mobile phone exists in the database or not. If it exists, it will return a pre-filled form. If not, it will return an empty form. Therefore, there is no need to change the values of the fields with javascript. Now, all you have to do is to take the response of the php and put it into a div under the first form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜