This topic is locked

setValue js checkbox

2/23/2012 10:12:15 PM
PHPRunner General questions
W
wildwally author

is there something other than 'on' to set the value of the checkbox on?
I want a apply all checkbox where user checks and all subsequent checkboxes become checked and vice versa. I'm able to remove the check 'off' but on is not working. I've also noticed that my 'off' does not trigger the on load code for the checkboxes it applies to, should it?

C
cgphp 2/24/2012

Post your code.

W
wildwally author 2/24/2012

var ctrlBFoverall = Runner.getControl(pageid, 'BFoverall');

var ctrlsystyp= Runner.getControl(pageid, 'SystemTypes');

var ctrlBFsystyp = Runner.getControl(pageid, 'BFsys');

var ctrlcondtyp= Runner.getControl(pageid, 'CondensingType');

var ctrlBFcondtyp = Runner.getControl(pageid, 'BFcond');
ctrlBFoverall.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlBFsystyp.setValue('on');

ctrlBFcondtyp.setValue('on');

}else{

ctrlBFsystyp.setValue('off');

ctrlBFcondtyp.setValue('off');

}

});

//-------

ctrlBFsystyp.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlsystyp.setDisabled();

}else{

ctrlsystyp.setEnabled();

}

});

//-------

ctrlBFcondtyp.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlcondtyp.setDisabled();

}else{

ctrlcondtyp.setEnabled();

}

});


W
wildwally author 3/2/2012



var ctrlBFoverall = Runner.getControl(pageid, 'BFoverall');

var ctrlsystyp= Runner.getControl(pageid, 'SystemTypes');

var ctrlBFsystyp = Runner.getControl(pageid, 'BFsys');

var ctrlcondtyp= Runner.getControl(pageid, 'CondensingType');

var ctrlBFcondtyp = Runner.getControl(pageid, 'BFcond');
ctrlBFoverall.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlBFsystyp.setValue('on');

ctrlBFcondtyp.setValue('on');

}else{

ctrlBFsystyp.setValue('off');

ctrlBFcondtyp.setValue('off');

}

});

//-------

ctrlBFsystyp.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlsystyp.setDisabled();

}else{

ctrlsystyp.setEnabled();

}

});

//-------

ctrlBFcondtyp.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlcondtyp.setDisabled();

}else{

ctrlcondtyp.setEnabled();

}

});



Still looking for some assitance with this one.

T
Tricause 3/2/2012

I have a similar issue. I can easily verify if all the values are selected with some dynamically loaded, comma delimited values. However, when I try to set the value of this control to this comma delimited set, it will only purge any selection. In other words, the getValues method properly returns the values in a comma delimited form whilst the setValues will not allow the setting of said comma delimited values.

C
cgphp 3/3/2012
ctrlBFoverall.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlBFsystyp.getDispElem().attr('checked','checked');

ctrlBFcondtyp.getDispElem().attr('checked','checked');

}else{

ctrlBFsystyp.getDispElem().removeAttr('checked');

ctrlBFcondtyp.getDispElem().removeAttr('checked');

}

});
S
smith 3/4/2012

Hi Cristian Gilè

I have a checkbox field in my form and I would like to add "check all" functionality to the same in list or inline edit page. How to acheive this?

Thanks in advance

Smith


ctrlBFoverall.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlBFsystyp.getDispElem().attr('checked','checked');

ctrlBFcondtyp.getDispElem().attr('checked','checked');

}else{

ctrlBFsystyp.getDispElem().removeAttr('checked');

ctrlBFcondtyp.getDispElem().removeAttr('checked');

}

});


C
cgphp 3/4/2012

The solution in this page should work:

ctrlBFoverall.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlBFsystyp.getDispElem().attr('checked','checked');

ctrlBFcondtyp.getDispElem().attr('checked','checked');

}else{

ctrlBFsystyp.getDispElem().removeAttr('checked');

ctrlBFcondtyp.getDispElem().removeAttr('checked');

}

});
S
smith 3/4/2012

Dear Cristian Gilè

Thanks for the reply,

Please tell me do I have to make an additional checkbox in the list page for the same, then what code I should use in the visual editor and the above code where will I place in the event, my field name is "present", this is to mark the database if present 1 and abscent 0 using checkbox

thank you

Smith



The solution in this page should work:

ctrlBFoverall.on('change', function(e){

if (this.getValue() == 'on')

{

ctrlBFsystyp.getDispElem().attr('checked','checked');

ctrlBFcondtyp.getDispElem().attr('checked','checked');

}else{

ctrlBFsystyp.getDispElem().removeAttr('checked');

ctrlBFcondtyp.getDispElem().removeAttr('checked');

}

});


C
cgphp 3/4/2012

There's already a "check all" box on the list page.

S
smith 3/5/2012

Dear Cristian Gilè

Please tell me how will I make use of the "check all" box for attendance purpose.if it is unchecked how will I post the value to database as absent.

If you could make it as a tips and tricks tutorial it will be nice.

Thank you

Smith >

There's already a "check all" box on the list page.

S
smith 3/5/2012

Dear Cristian Gilè

I mean how to implement this for a checkbox field in the list/ inline edit page

function Check(chk)

{

if(document.myform.Check_ctr.checked==true){

for (i = 0; i < chk.length; i++)

chk[i].checked = true ;

}else{
for (i = 0; i < chk.length; i++)

chk[i].checked = false ;

}

}


OR

function select_all(name,value){

for(var t, i=0;t=formblock.elements[name][i++];t.checked=value);

}
onclick="select_all('area[],1)"

else

onclick="select_all('area[]',0)


by using a custom checkbox in visual edit- something like this

t type="checkbox" name="Check_ctr" value="yes"

onClick="Check(document.myform.check_list)"><b>Check Control</b>


Regards

Smith

S
smith 3/6/2012

Dear Cristian Gilè / Jane / Admin

any help in this subject is really appreciated

Thanks in advance

Smith



Dear Cristian Gilè

I mean how to implement this for a checkbox field in the list/ inline edit page

function Check(chk)

{

if(document.myform.Check_ctr.checked==true){

for (i = 0; i < chk.length; i++)

chk[i].checked = true ;

}else{
for (i = 0; i < chk.length; i++)

chk[i].checked = false ;

}

}


OR

function select_all(name,value){

for(var t, i=0;t=formblock.elements[name][i++];t.checked=value);

}
onclick="select_all('area[],1)"

else

onclick="select_all('area[]',0)


by using a custom checkbox in visual edit- something like this

t type="checkbox" name="Check_ctr" value="yes"

onClick="Check(document.myform.check_list)"><b>Check Control</b>


Regards

Smith

C
cgphp 3/7/2012
S
smith 3/7/2012

Thank you for the link,

This woking in the visual editor with custome checkbox,, but how to get the name attribute of a field to it so that the custom checkbox will work in the inline edit grid for all records listed, associated a field value, In the grid, name and valuse are dynamic , how to apply it in phpr?

<INPUT

id=checkAllAuto name=checkAllAuto

type=checkbox>


$('#checkAllAuto').click(

function()

{

$("INPUT[type='checkbox']").attr('checked', $('#checkAllAuto').is(':checked'));

}

)



Regards

Smith



Check this article for inspiration: http://iknowkungfoo.com/blog/index.cfm/2008/7/9/Check-All-Checkboxes-with-JQuery