在经典 asp 中填充依赖下拉列表
我正在研究经典的asp,我需要填充下拉列表。在页面加载期间,所有大陆、所有国家和所有城市都应该填充在各自的下拉列表中。此外,一旦我选择说亚洲(大陆下降),国家/地区亚洲应该在国家下拉列表中填充,亚洲所有城市在城市下拉列表中填充。一旦我从国家下拉列表中选择一个特定的国家,比如印度,属于印度的所有城市都应该在城市下拉列表中填充。
我有一个 sql 过程,它从数据库返回结果。如何在不重新加载页面的情况下填充相同的下拉列表?有没有使用 javascript 的解决方案?
I am working on classic asp and i need to populate drop downs.During page load,all continents,all countries and all cities should get populated in their respective drop downs.Also,once i select say Asia(continent drop dwn),countries in Asia should get populated in country drop down and all cities of Asia in city drop down.and once i select a specific country from country drop down,say India.,all cities belonging to India should get populated in the city drop down.
I have a sql proc which returns the results from DB.How do I populate the same drop down without reloading the page?Is there any solution using javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这就需要在页面加载时内部加载大量的数据。国家和城市不会改变,因此数据是静态的。只需使用包含文件即可。
我们做这样的事情的方法是使用 onchange javascript 和 javascript 数组。您为您的国家/地区创建一个数组,然后为每个国家/地区创建一个单独的城市数组。当 onChange 事件发生在国家/地区时,您将触发另一个 javascript 例程,该例程使用适当的 javascript 城市数组重建下拉列表。
This requires a lot of data to be loaded internally when the page is loaded. Countries and cities do not change so the data is static. Simply use include files.
The way we did stuff like this was to use onchange javascript and javascript arrays. You create on array for your countries and then a separate city array for each country. When the onChange event happens on the country you fire off another javascript routine that rebuilds the dropdown using the appropriate javascript city array.
好吧,我认为 AJAX 是该问题的解决方案。对不起。
回复评论: google 给了我这个。
Well, I think AJAX was the solution to that problem. Sorry.
In response to comment: google gives me this.
在经典 ASP 中:
for
循环构建下拉菜单,该循环生成In Classic ASP:
for
loop on the server which generates each of the<option>
tags of the<select>
.<select>
at run time, on the client side.如果不重新加载页面,则无法在经典 ASP 中执行此操作。如果您不知道如何在 JavaScript 中执行此操作,则可以只使用第一个下拉列表,然后在做出选择后移至下一页,在链中添加下一个下拉列表。
我要做的就是构建第一个下拉菜单,并在更改时触发一些 AJAX 以点击另一个 ASP 页面以获取下一个下拉菜单,然后将其添加到页面中。
jQuery 可能会很容易地处理这个问题。
You can't do this in classic ASP without a page reload. If you don't know how to do it in javascript, you can just have the first drop down, and then move to the next page adding the next drop down in the chain after a selection is made.
What I would do, is build the first drop down and on change, fire off some AJAX to hit an another ASP page to get the next drop down and then add it to the page.
jQuery would probably handle this pretty easy.