Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

PHP variables to Javascipt

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Basso
Posts: 15
Joined: Sat Mar 30, 2024 9:53 am
Has thanked: 9 times

PHP variables to Javascipt

Unread post 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
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: PHP variables to Javascipt

Unread post 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);
Post Reply