To pass data between the client side in the browser and your server side component you need to use either AJAX or Web sockets base to communicate. Via a JS function on your page you make a connection with your server and execute the helper function and then return the data to the JS function that then changes the values on your page.
AJAX comes in two ...
I would use field groups instead of prefixes to organize fields in the form. This way no additional code is needed:
To specifically call the site application, you can use:
In Joomla 4, getApplication() will always return the global application object and doesn't take any arguments.
Assuming that your using a rockettheme gantry 4 template, the head renderer is already loaded (as of version joomla 3.7? several years ago in any case) now, and the included file is gone so just comment out the line in both error.php and offline.php
Alternatively you can check for the class so the template would still work in old Joomla if that's a thing.