Solved

check box in coldfusion mx 7

Posted on 2009-04-08
8
565 Views
Last Modified: 2013-12-24
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
Comment
Question by:khan02
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 

Author Comment

by:khan02
ID: 24101590
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
 

Author Comment

by:khan02
ID: 24101729
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
 

Author Comment

by:khan02
ID: 24101746
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
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 
LVL 16

Expert Comment

by:duncancumming
ID: 24109327
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
 
LVL 1

Expert Comment

by:Digitalmesh
ID: 24120888
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
 

Author Comment

by:khan02
ID: 24148568
yes, i want both radio button to be disabled ......
0
 
LVL 16

Accepted Solution

by:
duncancumming earned 500 total points
ID: 24150620

<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
 

Author Comment

by:khan02
ID: 24160378
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question