This topic is locked
[SOLVED]

Hide a field depending another one

3/8/2022 10:19:33 AM
PHPRunner General questions
P
Prof_Moriarti author

Hello all
Im trying to hide and show an field depending on a scroll down field also in the same table and screen
so what i´ve done is create a field event on the scroll down field and in the event change i have added the following code.

On client before
-> params["value"] = this.getValue();

On server side
-->
global $conn;
$sql2 = "SELECT * FROM equipamiento_movil where id_equip_mov=".$params["value"];

$consulta2 = $conn->query($sql2);
while($elemento2=mysqli_fetch_array($consulta2))
{
$nom_cto= $elemento2['Modelo'];
}

if (strpos($nom_cto, 'arifa') !== false)
{
$pageObject->showField("Caducidad_tarifa");
}
if (strpos($nom_cto, 'arifa') == false)
{
$pageObject->hideField("Caducidad_tarifa");
}

Well here i guess these works except these 2 lines

$pageObject->showField("Caducidad_tarifa");
$pageObject->hideField("Caducidad_tarifa");

im having this error

" Fatal error: Uncaught Error: Call to a member function hideField() on null in /var/www/html/Licencias/buttonhandler.php:971 Stack trace: #0 /var/www/html/Licencias/buttonhandler.php(124): fieldEventHandler_id_eqip_mov_event(Array) #1 {main} thrown in /var/www/html/Licencias/buttonhandler.php on line 971"

Any idea

Thxs in advance.

Nacho

P
Prof_Moriarti author 3/8/2022

the issue was cause
you can not use $pageObject variable in the Server part of the event.
Use

pageObj.hideField("Caducidad_tarifa");

in the Client After part instead: