【发布时间】:2010-02-10 16:05:35
【问题描述】:
像 Prototype/Scriptaculous 或 jQuery 这样的 javascript 库能否帮助我在网页上创建一个动态表单,我可以在其中根据组合框中选择的值显示一组不同的复选框?
【问题讨论】:
标签: javascript html
像 Prototype/Scriptaculous 或 jQuery 这样的 javascript 库能否帮助我在网页上创建一个动态表单,我可以在其中根据组合框中选择的值显示一组不同的复选框?
【问题讨论】:
标签: javascript html
是的。您可以在组合框的 onChanged 事件中轻松显示/隐藏所需的复选框。你甚至不需要特殊的 JavaScript 库来做到这一点。
【讨论】:
是的,因为所有这些库(框架)都有助于让跨浏览器更轻松地摆弄 DOM..
类似于(在 jQuery 中)
$(document).ready( //when the DOM is loaded invoke the following function
function(){
$('combobox_selector').change( // when someone changes the value of the combobox invoke the following function
function(){
$('some_checkbox_selector').hide(); // hide some checkboxes..
$('some_other_checkbox_selector').show(); // show some other checkboxes..
}
)
}
);
上面代码的 选择器 部分应该替换为确定在组合框的值更改时隐藏哪些项目以及显示哪些项目的逻辑。..
【讨论】: