Dynamicaly enable disable an object in a form
Posted: Thu Oct 18, 2018 3:29 pm
I have a form that includes a lookup table. I try to enable/disable another field of the form depending on the user selection.
To do it, I tried the following PHP code in the AB (AfterBrowse) PHP of the lookup value:
'device_count' is the name of the field to be enabled disabled
nuEnable('device_count');
and
nuDisable('device_count');
work as expected when used in the LUJS but not when called from the PHP code.
To do it, I tried the following PHP code in the AB (AfterBrowse) PHP of the lookup value:
Code: Select all
// Get the object type id
$recid = nuLookupRecord()->ID;
$s = "SELECT * FROM category WHERE category_id = '{$recid}'";
$t = nuRunQuery($s);
$r = db_fetch_object($t);
//nuDebug($r->category_countable);
if ($r->category_countable==1){
nuAddJavascript ("nuEnable('device_count');");
}else{
nuAddJavascript("nuDisable('device_count');");
}
nuEnable('device_count');
and
nuDisable('device_count');
work as expected when used in the LUJS but not when called from the PHP code.