我在冷融合表格上有 2 个复选框,如下所示。在页面加载时,我希望同时检查并根据选中的复选框显示查询结果。我的以下代码工作正常,除了我现在取消选中复选框并点击视图的场景。作为即时设置
form.chkbox=""
在页面加载时,即使我取消选中它们,它们仍然处于选中状态。我怎样才能让它们在页面加载时保持未选中状态。我尝试使用 JS 函数,但它似乎不起作用
<script type="text/javascript">
function callme(){
var box1 = document.getElementById('chkbox1').checked;
var box2 = document.getElementById('chkbox2').checked;
if (box1 && box2){
alert("checked") ;
}else{
box1.checked = false;
box2.checked = false;
}
}
</script>
<cfset form.chkbox="">
<form action="view_emp_qual.cfm?show=yes" method="post" name="Myform">
<table align="center">
<tr>
<td>
<cfif isDefined("form.chkbox") and (form.chkbox eq "" or listfind(form.chkbox, 1))>
<input type="checkbox" checked="checked" name="chkbox" id="chkbox1" value="1">
<cfelse>
<input type="checkbox" name="chkbox" id="chkbox1" value="1">
<input type="hidden" name="chkbox" id="chkbox1" value="1">
</cfif>
<strong> Agreement Only</strong>
<cfif isDefineD("form.chkbox") and (form.chkbox eq "" or listfind(form.chkbox, 2))>
<input type="checkbox" checked="checked" name="chkbox" id="chkbox2" value="2">
<cfelse>
<input type="checkbox" name="chkbox" id="chkbox2" value="2">
<input type="hidden" name="chkbox" id="chkbox2" value="2">
</cfif>
<strong>Active Employees</strong>
</td>
<td><input type="Submit" name="submitnow" value="View Selected" class="button" onclick="return callme();"> </td>
</tr>
</table>
</form>
<cfif not isDefined("form.chkbox")>
Query1
<cfelseif isDefined("form.chkbox") and ( listfind(form.chkbox, 1) eq 0 and listfind(form.chkbox, 2) eq 1)>
Query 2
<cfelseif isDefineD("form.chkbox") and (listfind(form.chkbox, 1) eq 1 and listfind(form.chkbox, 2) eq 0)>
query 3
<cfelse>
query4
</cfif>