【问题标题】:Show a different set of checkboxes in a webform based on the value chosen in a combobox根据在组合框中选择的值在 Web 表单中显示一组不同的复选框
【发布时间】:2010-02-10 16:05:35
【问题描述】:

像 Prototype/Scriptaculous 或 jQuery 这样的 javascript 库能否帮助我在网页上创建一个动态表单,我可以在其中根据组合框中选择的值显示一组不同的复选框?

【问题讨论】:

    标签: javascript html


    【解决方案1】:

    是的。您可以在组合框的 onChanged 事件中轻松显示/隐藏所需的复选框。你甚至不需要特殊的 JavaScript 库来做到这一点。

    【讨论】:

      【解决方案2】:

      是的,因为所有这些库(框架)都有助于让跨浏览器更轻松地摆弄 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..
                     }
        )
      }
      );
      

      上面代码的 选择器 部分应该替换为确定在组合框的值更改时隐藏哪些项目以及显示哪些项目的逻辑。..

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-09-18
        • 2014-04-04
        • 1970-01-01
        • 2013-12-08
        • 1970-01-01
        • 1970-01-01
        • 2016-07-13
        • 2020-08-18
        相关资源
        最近更新 更多