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