Solved

check box in coldfusion mx 7

Posted on 2009-04-08
8
563 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
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Email not working after mx record created 8 80
warning code: class php incomplete message 6 39
RSS FEED - PROPERLY FORMATTED URL 2 31
.CSS HTML Help 3 30
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

730 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