We have a form set up so that when the member gets to the thank you message, there's a print button so they can print out their submission and send it in with a check (we are an elementary school PTA). The form has drop down menus where one might select "Yes ($7.50)". So as a front-end user, I see "Yes ($7.50)" but in the back end I need that yes to actually equal $7.50 (or whatever the value is).
I have a string of code to calculate thanks to GreyHead🙂
And the only field that is calculating into the total (displayed with {total} on the thank you page) is 'donation' because it's a text box where they enter an actual amount. So logic tells me that I need to write some code that basically says that if field 'member_1_fee' is yes, then it equals a dollar amount.
I'm a coding virgin. If anyone could help me out here I would sincerely appreciate it! Just one line of code will help me tremendously - I can duplicate the rest. One other thing ... some of the drop downs have multiple options - so it's not a simple yes or no. If there is additional code for those types of situations I would greatly appreciate it as well.
Thanks so much!
Megan
ETA: I am looking around everywhere for this answer and would I need to insert custom code after each drop down to get a new column (?) in the database with the numeric value?
I have a string of code to calculate thanks to GreyHead🙂
<?php
$form->data['total'] = $form->data['member_1_fee'] + $form->data['member_2_fee'] + $form->data['student_1_shirt'] + $form->data['student_1_adult_shirt'] + $form->data['student_1_party_fund'] + $form->data['student_2_shirt'] + $form->data['student_2_adult_shirt'] + $form->data['student_2_party_fund'] + $form->data['student_3_shirt'] + $form->data['student_3_adult_shirt'] + $form->data['student_3_party_fund'] + $form->data['student_4_shirt'] + $form->data['student_4_adult_shirt'] + $form->data['student_4_party_fund'] + $form->data['donation'] + $form->data['faculty_shirt'];
?>And the only field that is calculating into the total (displayed with {total} on the thank you page) is 'donation' because it's a text box where they enter an actual amount. So logic tells me that I need to write some code that basically says that if field 'member_1_fee' is yes, then it equals a dollar amount.
I'm a coding virgin. If anyone could help me out here I would sincerely appreciate it! Just one line of code will help me tremendously - I can duplicate the rest. One other thing ... some of the drop downs have multiple options - so it's not a simple yes or no. If there is additional code for those types of situations I would greatly appreciate it as well.
Thanks so much!
Megan
ETA: I am looking around everywhere for this answer and would I need to insert custom code after each drop down to get a new column (?) in the database with the numeric value?
Okay, here's where I admit that I overthought this process waaaay too much.
It was as simple as 7.50=Yes in the dropdown menu configuration.
Is there a banging my head against the wall smiley? 😶
It was as simple as 7.50=Yes in the dropdown menu configuration.
Is there a banging my head against the wall smiley? 😶
Hi jwepta,
That's by far the easiest way if it works with your option set. If not you can add a 'look up' table using a Custom Code action to covert the form results into numbers in the the On Submit event. This may be more useful if you have several options with the same or similar values and you need to record the options selected as well as the cost.
Bob
That's by far the easiest way if it works with your option set. If not you can add a 'look up' table using a Custom Code action to covert the form results into numbers in the the On Submit event. This may be more useful if you have several options with the same or similar values and you need to record the options selected as well as the cost.
Bob
This topic is locked and no more replies can be posted.
