Hello community.
I have a simple form with next fields:
- textarea for entering digits,
- dropdown menu for select Yes or No.
I've found this useful
link which describes how to calculate sum of digits in several submitted forms. And I've stuck here due several reason:
1) the result is calculating by complex formula with a lot of arithmetic operations, so I'd like to use variables to simplify the main formula and make a part of calculations in variables. For example:
total = 10 * $time
time = ($Var1 + $Var2 + $Var3 + 2) * $Var4 + 3 + (4 * $Var5)
Var1 = Form1.value/(25 * $Var6)
Var6 = (Form2.value/10) * (Form3.value/10)
...
..etc
Yes, I can write a long whole formula, but there is second reason.
2) As I said above, here is several dropdown menus in the form and formula consists variables, which take the values in depends of selection (Yes/No). For example:
total = 10 * $time
time = ($Var1 + $Var2 + $Var3 + 2) * $Var4 + 3 + (4 * $Var5)
Var1 = Form1.value/(25 * $Var6)
Var6 = (Form2.value/10) * (Form3.value/10)
if Form4.value = Yes, then Var2 = 6, else Var2 = 0
if Form5.value < 500, then Var3 = 1
if Form5.value > 2000, then Var3 = 3, else Var3 = 2
..
So, the question is: is it possible to somehow use the calculation logic from the link above and display the result (total)?
One more question: is it possible to sent this result to Admin and User email? When I use this code
$modUserEmailText = $form->UserEmailText;
foreach($_POST['form'] as $component=>$value){
if(is_array($value)) $value = implode(',',$value);
if($value != ''){
$modUserEmailText .= '{'.$component.':caption}: {'.$component.':value}'."<br/>";
}
}
$userEmail['text'] = $modUserEmailText;
$userEmail['text'] = str_replace($placeholders, $values, $userEmail['text']);
it sends all submitted forms as well as Submit button:
Thank you for contacting us. We will get back to you as soon as possible.
This is your's submitted form:
name: myname
Form1: 1
Form2: 2
Form3: 3
Form4: Yes
Form5: 500
E-mail:
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
Submit: Submit
{formId:caption}: {formId:value}