|
Subject:
|
how to control two checkboxes
|
|
Posted By:
|
erin
|
Post Date:
|
10/27/2003 2:21:46 PM
|
How can I control two checkboxes with different names. I want to check only one checkbox at a time.
Thanks.
|
|
Reply By:
|
sal
|
Reply Date:
|
10/27/2003 2:45:06 PM
|
What exactly do you mean by "control two checkboxes with different names"
If you only need to hceck one item at a time, create radio buttons. (option Buttons/ option group).
It is not good programming to change the meaning of a checkbox to act as a option group.
Sal
|
|
Reply By:
|
erin
|
Reply Date:
|
10/27/2003 3:21:51 PM
|
I used to use the following codes for the controlling 2 checkboxes. <HEAD>
<SCRIPT LANGUAGE="JavaScript"> function checkBoxValidate(cb) { for (j = 0; j < 2; j++) { if (eval("document.myform.ckbox[" + j + "].checked") == true) { document.myform.ckbox[j].checked = false; if (j == cb) { document.myform.ckbox[j].checked = true; } } } } </script>
</HEAD> </head>
<body>
<BODY>
<form name=myform action ="NextPage.asp"> Selection 1<input type="checkbox" name="ckbox" onClick="javascript:checkBoxValidate(0)"><br> Selection 2<input type="checkbox" name="ckbox" onClick="javascript:checkBoxValidate(1)"><br>
---------------------------------------------------------------
Now I have been working with this code:
<form name="MyForm" METHOD="Post" ACTION="NextPage.asp <table><tr> <td>font size=3><b>Root Cause:</b></font> <input TYPE="checkbox" NAME="RootCause"></td> <td><font size=3><b>Fin Approval:</b></font> <input TYPE="checkbox" NAME="FinApproval"></td> </tr></table>
In the NextPage.asp: <%if Request.form("FinApproval") = "on" then%> STATEMENT1....... <%end if%> <%if Request.form("RootCause") = "on" then%> STATEMENT2....... <%end if%>
Is there any way that I can control the checkbox( means check only one checkbox at a time like radio button)with different checkbox names or any suggestion is welcome,
Thanks...
|
|
Reply By:
|
sal
|
Reply Date:
|
10/27/2003 3:47:32 PM
|
Use radio button. Do not confuse users.
Radio buttons = select one chechbox = select multiples.
do not change the rules
Sal
|
|
Reply By:
|
erin
|
Reply Date:
|
10/27/2003 4:02:05 PM
|
Is there any possiblitiy to unclick radio button then? As I know of, you can't unclick radio buttons without resetting the whole form. User has chance to click/unclick without reseting the whole form using the checkboxes. That's why I would like to use checkbox. Am I missing something?
|
|
Reply By:
|
sal
|
Reply Date:
|
10/27/2003 5:22:06 PM
|
Can you try setting the value to 0?
Sal
|