从数据库PHP MYSQL AJAX自动完成表单 [英] autocomplete form from database PHP MYSQL AJAX

查看:177
本文介绍了从数据库PHP MYSQL AJAX自动完成表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能指出我正确的方向,那么我应该能够弄清楚这一点,并让它工作......



基本上,我有一个位置的数据库,例如:

pre code $城市/城镇县
1纽伯里伯克郡
2普雷斯顿默西塞德郡

现在我的网站有一个表格,用户填写表明他们的地址,两个输入字段城市和县。在这里,我想要发生三件事情。

1)当用户开始进入他们的城市时,它会根据数据库的结果完成自动完成(这将包括他们的城市和县,该县只是为了识别当选择时只输入城市)。



2)用户选择城市后,它会自动从数据库中完成县字段。



3)完成这些工作后,我希望将来自市县的结果输入到一个隐藏的输入元素中。



我一直在寻找遍及互联网并且发现很多自动完成脚本:
http://ajaxdump.com/2010/08/11/10-cool-auto-complete-scripts-using-ajaxjquerymootoolsprototype/
http://www.jqueryrain.com/2012/03/35-best-ajax -jquery-autocomplete-tutorial-plugin-with-examples /



我在表单填写中发现了各种帖子,如:
jquery自动完成和PHP:根据自动填充字段中的选定选项,使用mySQL数据库中的数据填充输入字段



但我似乎无法让他们一起工作。我试图坚持使用PHP,MYSQL和JavaScript。如果需要的话,我很高兴使用AJAX,其他任何事情都超出了我对编程的了解。



我可能会这样做都是错误的,但任何反馈或信息都可以指向我非常感激地收到了。



非常感谢

解决方案



去数字,花了几天的时间试图找出它,然后在我们的上传中这篇文章我发现它!



对于其他人寻找相同的东西,它在这里 http://af-design.com/blog/2010/05/12/using-jquery- uis-autocomplete-populate-a-form /



享受!


I hope that someone can point me in the right direction, then I should be able to figure this out and get it working...

Basically, I have a database of locations such as:

ID   City/Town    County
1    Newbury      Berkshire
2    Preston      Merseyside

Now my website has a form that the user fills in to indicate their address, within a section I have two input fields 'city' and 'county'. Here I would like three things to happen.

1) When the user begins to enter their city it auto completes based on results from the database (this would include their city and county, the county is just for identification so when selected would just input the city).

2) Once the user selects their city it auto completes the county field from the database.

3) With all this done I would like the ID from the city and county result to be entered into a hidden input element.

I have been looking all over the internet and found plenty of auto complete scripts: http://ajaxdump.com/2010/08/11/10-cool-auto-complete-scripts-using-ajaxjquerymootoolsprototype/ http://www.jqueryrain.com/2012/03/35-best-ajax-jquery-autocomplete-tutorial-plugin-with-examples/

and I have found various posts on form filling such as: Jquery autocomplete and PHP: populating input field with data from mySQL database based on selected option in autocomplete field

but I just can't seem to get them to work together. I am trying to stick with PHP, MYSQL and JavaScript. I am happy to use AJAX if needed, anything else is going beyond my knowledge of programming.

I maybe going about this all wrong, but any feedback or information that can point me in the right direction will be very gratefully received.

Many thanks

解决方案

I actually found exactly the script I needed to do the job.

Go figure, spent a few days trying to figure it out, then within an our of uploading this post I found it!

For anyone else looking for the same thing its right here http://af-design.com/blog/2010/05/12/using-jquery-uis-autocomplete-to-populate-a-form/

enjoy!

这篇关于从数据库PHP MYSQL AJAX自动完成表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆