khan02
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>
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>
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>
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=fals e;
}
else
{
acc.enabled=false;
single.enabled=true;
}
</cfsavecontent>
<cfsavecontent variable="checkUncheck">
if(box.selected)
{
acc.enabled=true;
single.enabled=false;
email.text="";
access_action.checked=fals
}
else
{
acc.enabled=false;
single.enabled=true;
}
</cfsavecontent>
This refers to the first radio button:
access_action[0].checked=f alse;
This refers to the second radio button:
access_action[1].checked=f alse;
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)
access_action[0].checked=f
This refers to the second radio button:
access_action[1].checked=f
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=fa lse; 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.
The issue is in the line onclick="single.enabled=fa
ASKER
yes, i want both radio button to be disabled ......
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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=f alse;
access_action[0].checked=f alse;
}
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:cen ter;">
<cfinput type="submit" value="Submit" name="Submit">
</cfformgroup>
</cfform>
<cfsavecontent variable="checkUncheck">
if(box.selected)
{
acc.enabled=true;
single.enabled=false;
email.text="";
access_action[1].checked=f
access_action[0].checked=f
}
else
{
acc.enabled=false;
single.enabled=true;
}
</cfsavecontent>
<cfform name="access" method="post" action="index.cfm?content=
<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;
<!--- 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:cen
<cfinput type="submit" value="Submit" name="Submit">
</cfformgroup>
</cfform>
ASKER
<cfsavecontent variable="checkUncheck">
if(box.selected)
{
acc.enabled=true;
single.enabled=false;
}
else
{
acc.enabled=false;
single.enabled=true;
}
</cfsavecontent>