级联下拉列表 [英] Cascading Dropdown List

查看:117
本文介绍了级联下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个web应用程序,并尝试使用两个下拉列表编写表单。第二个下拉列表将取决于第一个下拉列表中的选择。任务本身不是太复杂,除非第一次选择完成后,我需要进行数据库调用来为第二个下拉菜单提取数据。这是我遇到困难的地方。这两个列表实际上都是从数据库填充的。

我正在使用python脚本处理这个问题,并一直在尝试使用onChange javascript函数来执行此操作。 Web应用程序内置在Zope中,页面模板可能是沿着Python脚本的一个选项。 你必须在这里使用Ajax和JavaScript的组合。您选择的下拉式Onchange事件调用JavaScript函数。这个javascript函数将向一个python脚本发出ajax请求,这个脚本实际上会使数据库命中并返回一个javascript变量中的响应。使用这个javascript变量,你可以编辑你的DOM并设置第二个选择框的html。



看看你是否可以从这里得到一些提示:
http://www.satya-weblog.com/2007 /04/dynamically-populate-select-list-by.html


I am working on a web app and trying to code a form with two dropdown lists. The list in the second dropdown will be dependent on the selection from the first one. The task itself isn’t too complicated except that once the first selection is made, I need to make a database call to pull the data for the second dropdown. This is where I am having difficulty. Both lists are in fact populated from a database.

I am working on this in a python script and have been trying to do this w/ an onChange javascript function. The web app is built in Zope and page templates may be an option along w/ the python scripts.

解决方案

you will have to use a combination of Ajax and javascript here. Onchange event of your select drop down call a javascript function. This javascript function will make a ajax request to a python script that will actually make a database hit and return you a response in a javascript variable. With this javascript variable you can edit you DOM and set the html of second select box.

see if u can get some hint from this: http://www.satya-weblog.com/2007/04/dynamically-populate-select-list-by.html

这篇关于级联下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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