?
Solved

check box in coldfusion mx 7

Posted on 2009-04-08
8
Medium Priority
?
567 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 1000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month8 days, 5 hours left to enroll

765 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