Forums

when is the return value of a function evaluated ?

jcm69 19 Sep, 2017
Hi,
In https://www.chronoengine.com/faqs/74-chronoforms6/5289-variable-shortcodes, it is said that :
The variable value is available ONLY AFTER the function has been processed.
OK, but when is the function evaluated ? After something has been typed in, say the text-field, and after the focus went to another field ? So, should I be able to display that return value in a button for example ?
Does Ajax has something to do with that ?
As you can see I'm an absolute beginner like in the song🙂
Cheers,
jc
Max_admin 20 Sep, 2017
Hi JC,

No, functions here are event actions and they run when the form is loaded or submitted, so the var is available during the load/submit routines.

If you want to do something on a button click then you need a field event and you will need to use JavaScript to write the code, but if you will do some server side task then you can also use AJAX and call a form event to do the processing, for example the field "reload" event uses AJAX as explained in the manual.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jcm69 20 Sep, 2017
Hi,
Let's say I have a text field which asks for the person's first name. I want a pop-up (or button) to appear when the text field is completed and the pop-up (or button) to display "Hi $first_name ! ". I should create an event "On change" in the text field which will call a PHP code that will build a variable for the pop-up (or button), right ? Just like in the Dynamic Dropdown demo ?

By the way, I tried to create an initialisation in the demo that initializes the 2nd menu (it's empty in the demo version).
I created a PHP event that I put in the load event of the Setup :
$options= [];
$options= ['1' => 'test', '2' => 'initialisation', '3' => 'deuxième menu'];
return $options;

But it doesn't work... I must be missing something but I don't know what ? Is it related to the "simply render the 2nd random field" ? I don't understand what it does😟
Thanks in advance,
jc
Max_admin 29 Sep, 2017
Hi JC,

The dynamic dropdown demo form is not working for you out of the box without any changes ?

You can use the same "reload" event to reload a button with the new content or reload a whole area, this can be done.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jcm69 04 Oct, 2017
Hi,
sorry for my late response...
Yes the demo worked fine out of the box. But when you haven't chosen something in the 1st, there's nothing in the second. May be it could display "Choose something in the 2st menu". And, if you choose say "So so" and then choose the "?" again , display that message ("Choose something in the 2st menu") again.
About "reload", there is no Advanced -> Reload Event in the button edition page. So how to do that in the same way as for the dropdown menus ?
Thanks for your response,
jc
Max_admin 09 Oct, 2017
Hi JC,

You can add a default empty option to the 2nd dropdown:
=Please choose something from the first dropdown

You may also return this empty option when the first dropdown choice i empty.

I have added the reload event for buttons on the todo list

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.