Link to home
Start Free TrialLog in
Avatar of khan02
khan02Flag for United States of America

asked on

check box in coldfusion mx 7

i have a checkbox, if i click on (checked) it, it should enable a panel and disable other panel. i do have my code working but when i uncheck the check box, then it doesn't do anything. not sure what i am missing. see code below.

<cfform name="access" method="post" action="index.cfm?content=admit" format="flash" height="300">
		<cfformgroup type="panel" label="Enable or Disable Access for a Single User" id="single" enabled="true" visible="true" style="text-align:center;">
			<cfinput type="text" name="email" required="false" message="Please enter a valid e-mail Address" label="E-mail (Login)" width="200">
			<cfinput name="access_action" type="radio" value="0" checked="false" label="Remove Access" required="false" message="You must select an option"> 
			<cfinput name="access_action" type="radio" value="1" checked="false" label="Allow Access" required="false" message="You must select an option">
			<cfinput type="hidden" name="formtype" value="single">
		</cfformgroup>
		<!--- onClick="acc.enabled=true; acc.visible=true; single.enabled=false; single.visible=true;" --->
		<cfinput type="checkbox" name="select" style="font-weight:bold;" label="If you like to enable or disable all user Access, please select this check box."  checked="false"  onclick="single.enabled=false; acc.enabled=true;">
		
		<cfformgroup type="panel" label="Enable or Disable Access for All User" id="acc" enabled="false" visible="true" style="text-align:center;">
			<cfinput type="radio" value="0" name="removeAll" label="Remove All Users' Access" tooltip="Will remove access for all incompleted applicants">
			<cfinput type="radio" value="1" name="removeAll" label="Allow All Users' Access" tooltip="Will allow access for all incompleted applicants">
			<cfinput type="hidden" name="accessType" value="all">
		</cfformgroup>
		
		<cfformgroup type="horizontal" style="horizontalAlign:center;">
			<cfinput type="submit" value="Submit" name="Submit">
		</cfformgroup>
		
	</cfform>

Open in new window

Avatar of khan02
khan02
Flag of United States of America image

ASKER

i think i got it. i had to create a function ....see below!!

<cfsavecontent variable="checkUncheck">
            if(box.selected)
            {
                  acc.enabled=true;
                  single.enabled=false;
            }
            else
            {
                  acc.enabled=false;
              single.enabled=true;
            }
            
      </cfsavecontent>
Avatar of khan02

ASKER

what if the radio was selected from the top panel and then by checking the box should also uncheck the radio from top panel, how to do that?

look at my code below, by checking the check box my 'email' fields bacomes empty, but i guess i am missing the properties for radio button. the code below doesn't work if i put radio buttons properties.

<cfsavecontent variable="checkUncheck">
            if(box.selected)
            {
                  acc.enabled=true;
                  single.enabled=false;
                  email.text="";
            }
            else
            {
                  acc.enabled=false;
              single.enabled=true;
            }
            
      </cfsavecontent>

Avatar of khan02

ASKER

here is the code that doesn't work:
<cfsavecontent variable="checkUncheck">
            if(box.selected)
            {
                  acc.enabled=true;
                  single.enabled=false;
                  email.text="";
                  access_action.checked=false;
            }
            else
            {
                  acc.enabled=false;
              single.enabled=true;
            }
            
      </cfsavecontent>
This refers to the first radio button:
access_action[0].checked=false;

This refers to the second radio button:
access_action[1].checked=false;

I'm not sure what your logic is; do you want both radio buttons unchecked, or just one of them?  If the latter you should be able to figure out the logic you'll need (another if statement probably)
HI
   The issue is in the line onclick="single.enabled=false; acc.enabled=true;" . All the click event in that check box will trigger the same event, that is the first panel will hide and second will enable.
Avatar of khan02

ASKER

yes, i want both radio button to be disabled ......
ASKER CERTIFIED SOLUTION
Avatar of duncancumming
duncancumming
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of khan02

ASKER

i applied your code and it didn't disable my checked radio button when i check the 'box'....
<cfsavecontent variable="checkUncheck">
            if(box.selected)
            {
              acc.enabled=true;
              single.enabled=false;
              email.text="";
                   access_action[1].checked=false;
              access_action[0].checked=false;
            }
            else
            {
                  acc.enabled=false;
              single.enabled=true;
            }
      </cfsavecontent>

      <cfform name="access" method="post" action="index.cfm?content=admit" format="flash" height="300">
            <cfformgroup type="panel" label="Enable or Disable Access for a Single User" id="single" enabled="true" visible="true" style="text-align:center;">
                  <cfinput type="text" name="email" style="text-align:left;" required="false" message="Please enter a valid e-mail Address" label="E-mail (Login)" width="200">
                  <cfinput name="access_action" type="radio" value="0" checked="false" label="Remove Access" required="false" message="You must select an option">
                  <cfinput name="access_action" type="radio" value="1" checked="false" label="Allow Access" required="false" message="You must select an option">
                  <cfinput type="hidden" name="formtype" value="single">
            </cfformgroup>
            <!--- onClick="acc.enabled=true; acc.visible=true; single.enabled=false; single.visible=true;" --->
            <!--- single.enabled=false; acc.enabled=true; --->
            <cfinput type="checkbox" name="box" style="font-weight:bold;" label="If you like to enable or disable all user Access, please select this check box."  checked="false"  onclick="#checkUncheck#">
            
            <cfformgroup type="panel" label="Enable or Disable Access for All User" id="acc" enabled="false" visible="true" style="text-align:center;">
                  <cfinput type="radio" value="0" name="removeAll" label="Remove All Users' Access" tooltip="Will remove access for all incompleted applicants">
                  <cfinput type="radio" value="1" name="removeAll" label="Allow All Users' Access" tooltip="Will allow access for all incompleted applicants">
                  <cfinput type="hidden" name="accessType" value="all">
            </cfformgroup>
            
            <cfformgroup type="horizontal" style="horizontalAlign:center;">
                  <cfinput type="submit" value="Submit" name="Submit">
            </cfformgroup>
            
      </cfform>