[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

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

0
khan02
Asked:
khan02
  • 5
  • 2
1 Solution
 
khan02Author Commented:
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>
0
 
khan02Author Commented:
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>

0
 
khan02Author Commented:
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>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
duncancummingCommented:
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)
0
 
DigitalmeshCommented:
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.
0
 
khan02Author Commented:
yes, i want both radio button to be disabled ......
0
 
duncancummingCommented:

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

Open in new window

0
 
khan02Author Commented:
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>
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now