styling the ouput table / email

How to remove empty rows from a CF email output table.

Overview

The issue occurs when form fields are empty but still generate table rows in the email, leading to unwanted blank spaces.
Use conditional PHP code in the email body template to check if a form field is empty and only output the corresponding HTML table row when it contains data.

Answered
hc hcohl 04 Feb, 2017
On submit my form gives out data via email.
Now I want to style these data. I want to delete empty data rows.
F.e.:
<tr><td>Other name(s):</td><td>{othername}</td></tr>
If "othername" is empty, I want to remove the whole <tr></tr>
I changed to:
<div id="cell">Other name(s): <div id="cell-value">{othername}</div></div>

I tried javascript, but it doesn't work:

$("div#cell-value:empty").parent().remove();

This javascript in the <head> of the output-email-code of chronoforms > setup > on submit > Email...???

Is there anybody with a better idea?
Max_admin Max_admin 04 Feb, 2017
Answer
Hi hcohl,

You will need php code in the email body for this:

<?php if(!empty($form->data['othername'])): ?>
<tr><td>Other name(s):</td><td>{othername}</td></tr>
<?php endif; ?>


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.