This topic is locked
[SOLVED]

 CHECKBOX-Field to "unchecked"

12/22/2018 12:23:11 PM
PHPRunner General questions
T
taumic author

In an EDIT mask I have different fields as checkboxes.

If the field 'info_aus_fb' (= crtlAusFB) is changed to "checked", the other checkbox fields should be set to "unchecked".
In "JavaScript OnLoad Event" I have the following:



var ctrlKeineInfo = Runner.getControl(pageid, 'info_keine');
var crtlAusFB = Runner.getControl(pageid, 'info_aus_fb');

var ctrlPostBroDt = Runner.getControl(pageid, 'info_pos_bro_dt');

var ctrlPostVgEn = Runner.getControl(pageid, 'info_pos_vg_en');

var ctrlPostWgEn = Runner.getControl(pageid, 'info_pos_wg_en');
function func() {

alert('Checked_1');

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

{

alert('Checked_2');

ctrlAusFB.getDispElem().attr('checked',false);

ctrlPostBroDt.getDispElem().attr('checked',false);

ctrlPostVgEn.getDispElem().attr('checked',false);

ctrlPostWgEn.getDispElem().attr('checked',false);

}

};
ctrlKeineInfo.on('click', func);


The ALERT messages 1 and 2 are triggered (only testing), but the other checkbox fields are not set to "unchecked".
How do I set a checkbox field to "unchecked" and display this in the mask?
Thank you and best regards
Michael

HJB 12/22/2018

Xmas greetings from Germany to Germany and for inspiration purposes only:
quote

Thanks - got the issue resolved. The script on the add page was ok, but on the edit page there were some incomplete lines of code, and that was stopping the javascripts to work. But the funny thing is that it stopped all javascripts from working on all the pages - List, Add & Edit pages.

unquote excerpt ex http://asprunner.com/forums/topic/22372-javascript-onload-event/

Admin 12/22/2018

I'm not sure why you need to use getDispElem() here. Simply use getValue() and setValue() functions.

https://xlinesoft.com/phprunner/docs/ctrl_getvalue.htm

https://xlinesoft.com/phprunner/docs/ctrl_setvalue.htm

T
taumic author 12/23/2018

Thank you for your hints, I have only little experience in JavaScript. What is the correct syntax to set a checkbox field to OFF?

I find many examples to query, but few to set checkboxes.
Thanks again
Michael
PS: xmas greetings from Bavaria back



var ctrlKeineInfo = Runner.getControl(pageid, 'info_keine');
var crtlAusFB = Runner.getControl(pageid, 'info_aus_fb');

var ctrlPostBroDt = Runner.getControl(pageid, 'info_pos_bro_dt');

var ctrlPostVgEn = Runner.getControl(pageid, 'info_pos_vg_en');

var ctrlPostWgEn = Runner.getControl(pageid, 'info_pos_wg_en');
function func() {

alert('Checked_1');



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

{

alert('Checked_2');
ctrlAusFB.setValue('') ;

ctrlPostBroDt.setValue('') ;

ctrlPostVgEn.setValue('') ;

ctrlPostWgEn.setValue('') ;
// ctrlAusFB.setValue('off') ;

// ctrlPostBroDt.setValue('off') ;

// ctrlPostVgEn.setValue('off') ;

// ctrlPostWgEn.setValue('off') ;
}

};
ctrlKeineInfo.on('click', func);
T
taumic author 12/24/2018

Thank you so much for your trouble. Unfortunately I could not solve the problem with "setValue()". Probably there was only one thing missing. The good news: I was able to generate a satisfactory solution with "getDispElem()". If someone knows how to solve this with "setValue()", I would be very interested.

Here is my solution for those who have the same questions:


var ctrlKeineInfo = Runner.getControl(pageid, 'info_keine');
var crtlAusFB = Runner.getControl(pageid, 'info_aus_fb');

var ctrlPostBroDt = Runner.getControl(pageid, 'info_post_bro_dt');

var ctrlPostVgEn = Runner.getControl(pageid, 'info_post_vg_en');

var ctrlPostWgEn = Runner.getControl(pageid, 'info_post_wg_en');

var ctrlTravelNewsEn = Runner.getControl(pageid, 'info_travel_news_en');

var ctrlBranchenNewsDt = Runner.getControl(pageid, 'info_branchen_news_dt');

var ctrlPressreleaseEn = Runner.getControl(pageid, 'info_pressrelease_en');

var ctrlPresseinfoDt = Runner.getControl(pageid, 'info_presseinfo_dt');

var ctrlRoadshowItbEn = Runner.getControl(pageid, 'info_roadshow_itb_en');

var ctrlRoadshowWtmEn = Runner.getControl(pageid, 'info_roadshow_wtm_en');

var ctrlMesseItbDt = Runner.getControl(pageid, 'info_messe_itb_dt');

var ctrlMesseWtmDt = Runner.getControl(pageid, 'info_messe_wtm_dt');
ctrlKeineInfo.on('change', function(e){

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

{

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

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

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

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

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

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

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

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

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

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

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

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

}

});


Merry Christmas
Michael

HJB 12/25/2018

Many thx 4 sharing your final, Xmas greetZ from Germany, Hamburg City area, to Bavaria!