I have 7 checkboxes in a form, but for simplicity, let’s say I have have 3 (amongst other items) and would like to email the individual checkbox results only if it is checked. For example:
[CODE]Please check which bottled water you like to drink:
[] Ozarka
[] Aquafina
[] Dasani
If the user checks Ozarka and Aquafina, then those are the only two that are sent in the email.
The form just mails a text file using a string to grab the info. And here’s what I’m currently using:
[CODE]$email_text = ‘Questionnaire Information: ‘ . “n” .
‘First Name: ‘ . $firstname . “n” .
‘Last Name: ‘ . $lastname . “n” .
‘Email: ‘ . $email . “n” .
‘Bottled water you drink: ‘ . $bottled_water1 . ‘ ‘ . $bottled_water2 . ‘ ‘ . $bottled_water3 . “n”
(more code after this that I didn’t include)
This works, but I’d like to be able to put commas or dashes between each variable so it’s more legible in the email. Those are easy enough to add, but if the user only selects Ozarka and Dasani, the output would end up looking like this:
[CODE]Ozarka, , Dasani
Notice the extra comma.
If they only pick Ozarka and Aquafina it looks like this:
[CODE]Ozarka, Aquafina,
Again, an extra comma.
Is it possible to add a conditional statement to output only the bottled water that is selected. I tried several things and couldn’t get it to work. Or can you create a new variable that will check for the conditions, let it construct the string, then use only that one variable to send the info?