This topic is locked
[SOLVED]

 custom checkbox to select

7/30/2012 1:41:43 AM
PHPRunner General questions
S
smith author

Please tell me what is wrong with the script below, aim is there is a custome check box and when it is checked it should check all the checkboxes available in a particular field 'present' in the inline edit mode. the custome check box should select all the inline edit items present colum checked or unchecked.

Regards

Smith



this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){

var val = $("#custom_checkbox:checked").val();
formObj.baseParams['custom_checkbox'] = val;
});

var ctrlpresent=Runner.getControl(pageid, 'present');
val.on('change', function(e){

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

{

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



}else{

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

}

});
C
cgphp 7/30/2012
val.on('change', function(e){


What does it mean?

S
smith author 7/30/2012


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


What does it mean?


I'm getting error on the same line, not able to make it work, it is intented for getting the custom checkbox value and change the 'present' coulmn checked on unchecked in inline edit.

how can I acheive the same?

Thanks in advance

Smith

C
cgphp 7/30/2012

The scope of val is wrong. It should be declared outside of the beforeSave event and should be a selector not a value. Anyway, if you want to add an event to a control, you have to use the getControl method. Try the following version:

this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){

var val = $("#custom_checkbox:checked").val();

formObj.baseParams['custom_checkbox'] = val;

});
var ctrlpresent = Runner.getControl(pageid, 'present');
$("#custom_checkbox").click(function() {

if($(this).is(':checked'))

{

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

}else{

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

}

});
S
smith author 7/30/2012

Thank you Cristian Gile
it works now

Smith



The scope of val is wrong. It should be declared outside of the beforeSave event and should be a selector not a value. Anyway, if you want to add an event to a control, you have to use the getControl method. Try the following version:

this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){

var val = $("#custom_checkbox:checked").val();

formObj.baseParams['custom_checkbox'] = val;

});
var ctrlpresent = Runner.getControl(pageid, 'present');
$("#custom_checkbox").click(function() {

if($(this).is(':checked'))

{

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

}else{

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

}

});


S
smith author 7/30/2012

btw how to hide the select all checkbox during inline edit
this is no working

var ctrlabc = $('#chooseAll_1'+pageid);
ctrlabc.hide();




Thank you Cristian Gile
it works now

Smith

S
smith author 7/30/2012

solved using

document.getElementById("chooseAll_1").style.display = 'none';


Thank you

Smith



btw how to hide the select all checkbox during inline edit
this is no working

var ctrlabc = $('#chooseAll_1'+pageid);
ctrlabc.hide();