选中复选框

时间:2013-07-08 15:37:27

标签: install4j

在我的安装程序中的表单上,我有一组复选框。 现在我想要另一个复选框,选中后将选中其他复选框

有谁知道如何实现这个目标?

由于

3 个答案:

答案 0 :(得分:2)

在复选框表单组件的“选择脚本”属性中,添加以下代码:

((JCheckBox)formEnvironment.getFormComponentById("123").
      getConfigurationObject()).setSelected(selected);

其中“123”必须替换为应选择的其他表单组件的ID。

答案 1 :(得分:0)

简单的jQuery:

<script>
$(document).ready(function(){
    // On clicking the master, check all checkbox
    $("#checkall").click(function() {
        // find all checkboxes with the class 'checkboxes'
        // and make it checked/unchecked to match the master checkbox
        $('input[type="checkbox"].checkboxes')
           .attr("checked", $(this).is(":checked"))
       ;
    });
});
</script>

添加一个简单复选框以充当主控器以启用/禁用其余

<input title="Check all" id="checkall" 
       type="checkbox" class="checkbox" value="1" 
/>

<input class="checkboxes checkbox" type="checkbox" />
<input class="checkboxes checkbox" type="checkbox" />
<input class="checkboxes checkbox" type="checkbox" />

答案 2 :(得分:0)

您可以使用简单的javascript来执行此操作:

<div id="page">
<p>
<input id="chkFile1" type="checkbox" title="File 1" />File 1</p>
<p>
<input id="chkFile2" type="checkbox" title="File 2" />File 2</p>
<p>
<input id="chkFile3" type="checkbox" title="File 3" />File 3</p>
<p>
<input id="chkFile4" type="checkbox" title="File 4" />File 4</p>
<p>
<input id="chkFile5" type="checkbox" title="File 5" />File 5</p>
<p>
<input id="chkAllFiles" type="checkbox" title="All Files"  onchange="selectAllFiles(this.checked);" />All Files</p>
</div>

然后是剧本:

<script type="text/javascript">
    function selectAllFiles(c) {
       for (i = 1; i <= 5; i++) {
           document.getElementById('chkFile' + i).checked = c;
       }
    }
</script>
相关问题