Page 1 of 1

PHP variables to Javascipt

Posted: Tue Apr 30, 2024 7:12 pm
by Basso
Good morning

I created a form that refers to a table (edit) with only two fields.
in this form in the BS function I execute a query on another table to retrieve another value, then I perform some calculations.

After saving the entered data, I would like the result of the previously performed calculation to be visible in a 'text area' of the same form..

in the BS function I try to use the following command:

nuSetNuDataValue($nudata, nuHash()['nuFORMdata'][0]->id, 'text', $mydata);

where $mydata is the php variable that contains the result of the calculation.

I then thought about creating a javascript function afterSave { } .

Is this the correct way or is there a better way?
If yes, what is the command to insert into the javascript function that allows to update a text form field?

Thanks in advance

Re: PHP variables to Javascipt

Posted: Wed May 01, 2024 4:19 pm
by kev1n
Use nuAddJavaScript() to execute JS when the form loads, e.g.

Code: Select all

$js = "nuSetValue('object_id_of_textarea, '$SomephpVariable') ";
nuAddJavaScript($js);