0
我在Coldfusion表单上有2个复选框,如下所示。在页面加载时,我希望两者都被检查 ,并根据选中的复选框显示查询结果。我有下面的代码工作正常,除了scernario我取消勾选复选框,现在点击查看。当im设置在Coldfusion的页面加载复选框
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>
是不是在这里解决? http://stackoverflow.com/questions/15770423/checkbox-in-a-coldfusion-form – 2013-04-10 15:30:17
'在页面加载我希望两个被检查',你也说'我怎样才能让他们保持未加载页面加载。这是什么? – 2013-04-10 15:31:15
第一次加载页面时,必须检查它们。哪个在工作。当我取消选中它们并立即查看时,由于,它们仍然被检查。我希望现在清楚谢谢 –
user747291
2013-04-10 15:37:04