Forums

hide empty fields in email & make a sum of values

arrowsvienna 10 Jan, 2010
Hi @ all,

thanx alot for your answers on my last question, everything worked fine, good job!
I almost finished my forms but have still 2 problems:

1.) In my form people can choose from two products with each some variations. So I have 6 fields in total for product choose. What I want is that in the email template should be the values of the fields like:
{product1} {product1_attribute1} {product1_attribute2}
{product2} {product2_attribute1} {product2_attribute2}
If someone orders just one of the two products, 3 fields will stay empty. Those fields should not be displayed in the email. If I send such an email, the fields with values diplay the right values, but the empty fields are displayed as code eg. "{product1}". How can I manage that empty fields are just not contained in the email? (with numeric fields it seems to work, I think text fields are the problem).

2.) I have the price of each product contained in a longer text field. What i need is the total sum (price) in the email. So I would need to extract the numbers from the text fields and add them. Or is it possible to automatically send a value (the price) in an extra field depending if the product is chosen and add those extra fields at the end?

Thanx for your help,
Peter
GreyHead 10 Jan, 2010
Hi Peter,

There's a little trick that I think might hide the empty fields. Add value=' ' into the form input - with just a space between the quotes. This has some side effects, you can't make the fields required and the space may be saved in the database.

Otherwise you need to run a little PHP in the Email template to only show the inputs that have results.

To add up the values you can either do it with JavaScript in the form and set the total in a hidden filed, or you can do ti with PHP in the OnSubmit Before box.

Bob
This topic is locked and no more replies can be posted.