This topic is locked

How I can disable field from beginning or refresh the list page if checkboxes marked

1/15/2024 4:33:29 AM
PHPRunner Tips and Tricks
A
Axel Fricke author

Hello together,

This is my first topic here and I need your help.

I have a list page in spreadsheet mode with checkboxes. In events for add and edit page I set have set following script.
If I marked checkbox/field "SLOT_W1" as example, then the checkbox SLOT_L5 and TIME_L5 should be disabled.
This works fine when I change or mouseover checkboxes.

But if I refresh the list page (F5) all fields will be show and not hidden or readonly.

Can someone help me?

var ctrl_Datum = Runner.getControl(pageid, 'DATUM');

var ctrl_W1 = Runner.getControl(pageid, 'SLOT_W1');
var ctrl_W2 = Runner.getControl(pageid, 'SLOT_W2');
var ctrl_W3 = Runner.getControl(pageid, 'SLOT_W3');

var ctrl_L1 = Runner.getControl(pageid, 'SLOT_L1');
var ctrl_L2 = Runner.getControl(pageid, 'SLOT_L2');
var ctrl_L3 = Runner.getControl(pageid, 'SLOT_L3');
var ctrl_L4 = Runner.getControl(pageid, 'SLOT_L4');
var ctrl_L5 = Runner.getControl(pageid, 'SLOT_L5');
var ctrl_L6 = Runner.getControl(pageid, 'SLOT_L6');

var ctrl_T_W1 = Runner.getControl(pageid, 'TIME_W1');
var ctrl_T_W2 = Runner.getControl(pageid, 'TIME_W2');
var ctrl_T_W3 = Runner.getControl(pageid, 'TIME_W3');

var ctrl_T_L1 = Runner.getControl(pageid, 'TIME_L1');
var ctrl_T_L2 = Runner.getControl(pageid, 'TIME_L2');
var ctrl_T_L3 = Runner.getControl(pageid, 'TIME_L3');
var ctrl_T_L4 = Runner.getControl(pageid, 'TIME_L4');
var ctrl_T_L5 = Runner.getControl(pageid, 'TIME_L5');
var ctrl_T_L6 = Runner.getControl(pageid, 'TIME_L6');
function disable_enable_slots() {
if(ctrl_Datum.getValue()==''){

ctrl_W1.setDisabled(); ctrl_W1.setValue(null); ctrl_T_W1.setValue(null); ctrl_T_W1.hide();
ctrl_W2.setDisabled(); ctrl_W2.setValue(null); ctrl_T_W2.setValue(null); ctrl_T_W2.hide();
//ctrl_W3.setDisabled(); ctrl_W3.setValue(null); ctrl_T_W3.setValue(null); ctrl_T_W3.hide();

ctrl_L1.setDisabled(); ctrl_L1.setValue(null); ctrl_T_L1.setValue(null); ctrl_T_L1.hide();
ctrl_L2.setDisabled(); ctrl_L2.setValue(null); ctrl_T_L2.setValue(null); ctrl_T_L2.hide();
ctrl_L3.setDisabled(); ctrl_L3.setValue(null); ctrl_T_L3.setValue(null); ctrl_T_L3.hide();
ctrl_L4.setDisabled(); ctrl_L4.setValue(null); ctrl_T_L4.setValue(null); ctrl_T_L4.hide();
ctrl_L5.setDisabled(); ctrl_L5.setValue(null); ctrl_T_L5.setValue(null); ctrl_T_L5.hide();
//ctrl_L6.setDisabled(); ctrl_T_L6.setValue(null); ctrl_T_L6.hide();
}

//Wenn das Datum nicht leer ist, setze Waggon1 und LKW1 auf aktiv
if(ctrl_Datum.getValue()!=''){

ctrl_W1.setEnabled();
ctrl_L1.setEnabled();

if(ctrl_W1.getValue()==0){ctrl_T_W1.hide(); ctrl_T_W1.setValue(null);} else ctrl_T_W1.show();
if(ctrl_W2.getValue()==0){ctrl_T_W2.hide(); ctrl_T_W2.setValue(null);} else ctrl_T_W2.show();

if(ctrl_L1.getValue()==0){ctrl_T_L1.hide(); ctrl_T_L1.setValue(null);} else ctrl_T_L1.show();
if(ctrl_L2.getValue()==0){ctrl_T_L2.hide(); ctrl_T_L2.setValue(null);} else ctrl_T_L2.show();
if(ctrl_L3.getValue()==0){ctrl_T_L3.hide(); ctrl_T_L3.setValue(null);} else ctrl_T_L3.show();
if(ctrl_L4.getValue()==0){ctrl_T_L4.hide(); ctrl_T_L4.setValue(null);} else ctrl_T_L4.show();
if(ctrl_L5.getValue()==0){ctrl_T_L5.hide(); ctrl_T_L5.setValue(null); } else ctrl_T_L5.show();
}
};
ctrl_Datum.on('change', disable_enable_slots);
ctrl_Datum.on('mouseover', disable_enable_slots);
ctrl_W1.on('change', disable_enable_slots);
ctrl_W1.on('mouseover', disable_enable_slots);
ctrl_W2.on('change', disable_enable_slots);
ctrl_W2.on('mouseover', disable_enable_slots);
//ctrl_W3.on('change', disable_enable_slots);
//ctrl_W3.on('mouseover', disable_enable_slots);
ctrl_L1.on('change', disable_enable_slots);
ctrl_L1.on('mouseover', disable_enable_slots);
ctrl_L2.on('change', disable_enable_slots);
ctrl_L2.on('mouseover', disable_enable_slots);
ctrl_L3.on('change', disable_enable_slots);
ctrl_L3.on('mouseover', disable_enable_slots);
ctrl_L4.on('change', disable_enable_slots);
ctrl_L4.on('mouseover', disable_enable_slots);
ctrl_L5.on('change', disable_enable_slots);
ctrl_L5.on('mouseover', disable_enable_slots);
//ctrl_L6.on('change', disable_enable_slots);
//ctrl_L6.on('mouseover', disable_enable_slots);

Thanks in advance!
Axel

A
Axel Fricke author 1/15/2024

I tried in List page:After record processed this

if($data["SLOT_W1"] !=0){
//echo $data["SLOT_W1"];
//$pageObject->hideItem("simple_grid_field20", $recordId);
$pageObject->hideField("SLOT_L5", $recordId);
$pageObject->hideField("TIME_L5", $recordId);
}
else
{
//$pageObject->showItem("simple_grid_field20", recordId);
$pageObject->showField("SLOT_L5", $recordId);
};

...but then the script in Add page: JavaScript OnLoad event or Edit page: JavaScript OnLoad event doesn't work because checkbox are not exists

admin 1/15/2024

Call your disable_enable_slots() function once at the end of the Javascript OnLoad event.