【发布时间】:2012-06-07 01:12:43
【问题描述】:
我希望有人能指出我正确的方向,然后我应该能够解决这个问题并让它发挥作用......
基本上,我有一个位置数据库,例如:
ID City/Town County
1 Newbury Berkshire
2 Preston Merseyside
现在我的网站有一个表格供用户填写以表明他们的地址,在一个部分中我有两个输入字段“城市”和“县”。在这里,我希望发生三件事。
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) 一旦用户选择了他们的城市,它会自动从数据库中完成县域。
3) 完成所有这些后,我希望将城市和县结果中的 ID 输入到隐藏的输入元素中。
我一直在寻找整个互联网,并发现了大量的自动完成脚本: 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 autocomplete and PHP: populating input field with data from mySQL database based on selected option in autocomplete field
但我似乎无法让他们一起工作。我试图坚持使用 PHP、MYSQL 和 JavaScript。如果需要,我很乐意使用 AJAX,其他任何事情都超出了我的编程知识范围。
我可能在这件事上做错了,但任何可以为我指明正确方向的反馈或信息将不胜感激。
非常感谢
【问题讨论】:
标签: php mysql ajax forms autocomplete