您建议使用哪些 PHP 库来实现以下功能:
- 三个依赖下拉列表
- 三个 XML 数据源
- 基于 AJAX
本质上,我想创建一个 XML 数据库并连接一个表单,允许用户选择三个不同的依赖参数:
- 用户点击地区
- 用户点击地区(按地区过滤)
- 用户点击车站(按地区过滤)
即使我想使用 PHP 和 XML,一般问题是:
- 一个 XHTML 表单
- 三个相关的级联下拉列表
- 三个平面文件(无关系数据库)对于列表数据的
解决方案必须高效、简单、可靠、跨浏览器。
您会推荐哪些技术来解决该问题?
谢谢你!
What PHP libraries would you recommend to implement the following:
- Three dependent drop-down lists
- Three XML data sources
- AJAX-based
Essentially, I'd like to create an XML database and wire up a form that allows the user to select three different dependent parameters:
- User clicks Region
- User clicks District (filtered by Region)
- User clicks Station (filtered by District)
Even though I would like to use PHP and XML, the general problem is:
- One XHTML form
- Three dependent, cascading drop-down lists
- Three flat files (no relational database) for the list data
The solution must be efficient, simple, reliable, and cross-browser.
What technologies would you recommend to solve the problem?
Thank you!
发布评论
评论(2)
我想说的是 jQuery 和 自动完成插件。
autocomplete()
增强它们下拉列表的 result
事件,存储所选选项。DOMDocument
和DOMXPath
来获取数据,自动完成插件具有内置的客户端缓存,可以减轻服务器上的负载I'd say jQuery and the Autocomplete plugin.
autocomplete()
result
event of the dropdowns, storing the selected option.DOMDocument
andDOMXPath
to get the data, the autocomplete plugin has built-in client side caching do ease load on the serverVanilla php 和一个好的 JavaScript 框架就足够了。
您需要构建一个 php 脚本来根据提供的父过滤器生成经过过滤的地区和车站列表(以 xml 或 json 形式推出数据)。 php需要解析xml数据并根据条件过滤列表(显然数据库会比手动解析xml更好地处理这个问题)
然后使用js框架在每次父列表的值发生变化时查询php文件。 js 框架不是必需的(实际上会导致一些膨胀),但是它将使开发应用程序成为一项简单的任务。
就我个人而言,我推荐 jQuery,因为它易于学习,但任何流行的 js 框架都会产生相同的结果。
Vanilla php and a good JavaScript framework is all you'd need.
You'll need to build a php script to generate filtered lists of districts and stations based on the provided parent filter (pushing out the data as either xml or json). The php will need to parse the xml data and filter the list based on criteria (obviously a db will handle this better than manually parsing xml)
Then use a js framework to query the php files every time the parent list's value changes. A js framework isn't required (and actually cause some bloat), however it'll make developing the app an easy task.
Personally I'd recommend jQuery due to the easy learning curve, but any popular js framework will yield the same result.