Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Check all Checkboxes Using ColdFusion Form field binding

Community Beginner ,
May 05, 2011 May 05, 2011

I have a group of check boxes and another single checkbox and when I click on that single check box all the checkboxes in the group should be checked. I need it without Javascript . I need to use Coldfusion's form field bind technique. Please help

3.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2011 May 06, 2011

Do you know that the binding of CF is done via JS ?

It saves you the need to write a cross platform/browsers js code, but it can not be doen "without javascript" at all, unless you will create a flash form for example.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 06, 2011 May 06, 2011

Thanks for the reply. I am looking for something below. This works fine when doing  the check all. I need a similar technique (form field binding) when uncheck the checkbox that should uncheck all the checked checkboxes. Please note that this works only when we give bindAttribute="checked"

<cfform id="myForm1" format="html">

check all:<cfinput type="checkbox" name="approved" id="approved" value="1" label="CheckyBox" />

<cfinput type="text" name="textBoxName" bind="{myForm1:approved.checked@click}"/>

<cfinput type="checkbox" id="bapproved1" bindAttribute="checked" name="bapproved" value="1" label="CheckyBox2" bind="{myForm1:approved.checked@click}"/>

<cfinput type="checkbox" id="bapproved2" bindAttribute="checked" name="bapproved" value="1" label="CheckyBox3" bind="{myForm1:approved.checked@click}"/>

<cfinput type="checkbox" id="bapproved3" bindAttribute="checked" name="bapproved" value="1" label="CheckyBox4" bind="{myForm1:approved.checked@click}"/>

</cfform>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2011 May 06, 2011

I know you said no JS .... but I coudln't get it to work any other way ...

but like that :

<script type="text/javascript">
function doitpro(flag)
{
return flag;
}
</script>

<BR /><BR />
<cfform name="myForm1">
All <cfinput type="checkbox" name="controler" checked="false"><BR />
<cfinput type="checkbox" name="optionscheckbox1" bindattribute="checked" bind="javascript:doitpro({myForm1:controler.checked@click})" value="11"> options = 11 <BR />
<cfinput type="checkbox" name="optionscheckbox2" bindattribute="checked" bind="javascript:doitpro({myForm1:controler.checked@click})"  value="12"> options = 12 <BR />
<cfinput type="checkbox" name="optionscheckbox3" bindattribute="checked" bind="javascript:doitpro({myForm1:controler.checked@click})" value="13"> options = 13 <BR />
</cfform>

try it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 06, 2011 May 06, 2011

Sorry to bother you. Actually in my code it doesn't require any javascript. My code works in CHECK ALL scenario

I need your help on how to do UNCHECK so that all the checked boxes are got unchecked. So in a nut shell I would say The code below works fine for Check all. Can you make some changes in the below code so that on click of the checked box (i.e on uncheck) all the checked boxes got unchecked.

Your code also works fine only in Check All situation. You can either make changes in your code or the below my code to implement uncheck ALL

<cfform id="myForm1" format="html">

check all:<cfinput type="checkbox" name="approved" id="approved" value="1" label="CheckyBox" />

<cfinput type="text" name="textBoxName" bind="{myForm1:approved.checked@click}"/>

<cfinput type="checkbox" id="bapproved1" bindAttribute="checked" name="bapproved" value="1" label="CheckyBox2" bind="{myForm1:approved.checked@click}"/>

<cfinput type="checkbox" id="bapproved2" bindAttribute="checked" name="bapproved" value="1" label="CheckyBox3" bind="{myForm1:approved.checked@click}"/>

<cfinput type="checkbox" id="bapproved3" bindAttribute="checked" name="bapproved" value="1" label="CheckyBox4" bind="{myForm1:approved.checked@click}"/>

</cfform>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2011 May 06, 2011

I was not clear ...

Yes your code do half the work ... I couldn't find and other way to do it except using that samll peice of JS code.

If you do find one that will work only on BIND let me know

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 06, 2011 May 06, 2011

Given that the bind method you want to use is just another form of javascript, and that what you are trying to accomplish is incredibly simple with normal javascript, why are you spending so much time and effort making easy things difficult?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 02, 2011 Jun 02, 2011
LATEST

The below JS works fine

function doBind(flag)

{

if(flag=='false')

return '';

else

return flag

}

<cfform id ="frmReclassAdj">

<input type="checkBox" value="chkAllStir" id="stir_all_checkbox"  name="stir_all_checkbox">

<cfinput  type="checkBox" name="chkAdjSelector" bindattribute="checked" bind="javascript:doBind({frmReclassAdj:stir_all_checkbox.checked@click})" value="" id="checkBoxID_#r_no#">

</cfform>

This works fine when check All and Uncheck All

Message was edited by: balettan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources