Using embedded PHP in Javascript functions in Chronoforms 7

CraigH 16 Dec, 2022
When you add a custom HTML element to a page you have an advanced option to embed php which works.
When you add a custom javascript element to a page that advanced option for PHP does not appear and any embedded php is left as is.

I need to call a javascript function from complex action event and this function needs to access data that is available server side in php.
Even the simple function below fails (but works if the php code is removed).

var formData = <?php echo '\"hello world\"'; ?>;
function calcCourseCost()
{
alert("calcCourseCost called with formData = " + formData);
return 0;
}

Does anyone know how to resolve this or perhaps another way to get the data available to the javascript function
CraigH 16 Dec, 2022
1 Likes
Ok it seems you can use the shortcodes from the cheatsheet to get at the data required.
You need to login to be able to post a reply.