Forums

set string depending on dropdown list

tamerlano 23 Apr, 2020
Hello,
i need to set a string to put in the email that i send to the user, depending on the choice that he do in a dropdown list. How can i do that?
thanks in advance and regards
Max_admin 23 Apr, 2020
please tell us more info, you want a different text for each option or something else ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
tamerlano 23 Apr, 2020
Yes, i have a dropdown list with three choices, the structure is "course code", "course description"; in the email, that i send to users who compile the form, i need to put the price of the course choosed. So what i need is associate a small string (a number actually) to each line of dropdown list, and use it in the email
GreyHead 24 Apr, 2020
Hi tamerlano,

You can use a Custom Code action before the email action to look at the submitted data and add the appropriate prices to the form data for display.

Bob
tamerlano 24 Apr, 2020
Hi Bob,
thanks, but i have no enough skill to do that, do you have perhaps an example code?
tamerlano 24 Apr, 2020
Answer
1 Likes
Done! In Custom Code after On submit i put this code:
<?php if ($form->data['corso'] == 'aaa') {$form->data['totalPrice'] = 1;} elseif ($form->data['corso'] == 'bbb') {$form->data['totalPrice'] = 2;}
else {$form->data['totalPrice'] = 3;}
?>
and then i put {totalPrice} in my email. It works, thanks you very much.
Max_admin 30 Apr, 2020
This feature is available in v7 as "Server options" for the "Dropdown" field, you will be able to set a list of values to get from the dropdown apart from the real options values, the values will be under {var:dropdown_name}

But at the moment v7 is still in Beta state and its not recommended to use it for production!
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.