Hello - I have a form that is running a PHP script and don't want it to send information to the email for fields unless they have been completed

so, ONLY if the text filled has an input do I want it to show and for it to show the option value for it too

e.g. Only include on the email when <input type="text" name="sailing1" /> has a value and include the related option value <select name="sailingEx1">
<option value="Not Playing!">Please select</option>
<option value="Experienced">Expert</option>
<option value="Some Experience">Not too
bad</option>


This is the HTML code

<table width="500" border="0" cellspacing="1" cellpadding="1">
                                <!--DWLayoutTable-->
                                <tr> 
                                  <td width="104" rowspan="2" align="center" valign="top"> 
                                    <div align="left"><br>
                                    </div>
                                                                  <p><br />
                                    </p></td>
                                  <td width="4" height="89">&nbsp;</td>
                                  <td width="190" valign="top"> <p align="center"> 
                                      <input type="text" name="sailing1" />
                                      <br>
                                      <input type="text" name="sailing2" />
                                      <br>
                                      <input type="text" name="sailing3" />
                                      <br>
                                      <input type="text" name="sailing4" />
                                      <br>
                                    </p></td>
                                  <td width="38">&nbsp;</td>
                                  <td width="158" rowspan="3" valign="top"> <p align="center"> 
                                      <select name="sailingEx1">
                                        <option value="Not Playing!">Please select</option>
                                        <option value="Experienced">Expert</option>
                                        <option value="Some Experience">Not too 
                                        bad</option>
                                        <option value="No Experience">Complete 
                                        Novice</option>
                                      </select>
                                      <br>
                                      <select name="sailingEx2">
                                        <option value="Not Playing!">Please select</option>
                                        <option value="Experienced">Expert</option>
                                        <option value="Some Experience">Not too 
                                        bad</option>
                                        <option value="No Experience">Complete 
                                        Novice</option>
                                      </select>
                                      <br>
                                      <select name="sailingEx3">
                                        <option value="Not Playing!">Please select</option>
                                        <option value="Experienced">Expert</option>
                                        <option value="Some Experience">Not too 
                                        bad</option>
                                        <option value="No Experience">Complete 
                                        Novice</option>
                                      </select>
                                      <br>
                                      <select name="sailingEx4">
                                        <option value="Not Playing!">Please select</option>
                                        <option value="Experienced">Expert</option>
                                        <option value="Some Experience">Not too 
                                        bad</option>
                                        <option value="No Experience">Complete 
                                        Novice</option>
                                      </select>
                                    </p></td>
                                </tr>
                                <tr> 
                                  <td height="23">&nbsp;</td>
                                  <td>&nbsp;</td>
                                  <td>&nbsp;</td>
                                </tr>
                                <tr> 
                                  <td height="23"></td>
                                  <td></td>
                                  <td></td>
                                  <td></td>
                                </tr>
                                <tr> 
                                  <td height="1"></td>
                                  <td></td>
                                  <td></td>
                                  <td></td>
                                  <td></td>
                                </tr>
                              </table>

PHP code

<tr>
   <td>Sailing 1:</td>
   <td>$sailing1 </td>

</tr>
<tr>
   <td>Sailing Exp 1:</td>
   <td>$sailingEx1 </td>
</tr>

Thanks

This is a job for javascript.

Something in the textbox onchange event:

(document.getElementsByName("sailing1")[0].value == "")? document.getElementsByName("sailingEx1")[0].style.visibility = "hidden" : document.getElementsByName("sailingEx1")[0].style.visibility = "visible";
...

You would need to hide the select boxes to be invisible when the page loads:

document.getElementsByName("sailngEx1")[0].style.visibilty = "hidden";
...

This would only work if the user has javascript turned on. If it's turned off, the select items would still be displayed.

Then in PHP, you need to check if the textbox is empty before adding the corresponding select to the email.

I have 16 of these events each one has an option for 4 participants and the experience of each.

On the HTML I don't want to surpress anything, only when the information is submitted to email via the PHP script

Thanks - I only want to surpress the information submitted to email via the PHP script, not in the HTML doc

I'm not sure what you mean by suppress. Can you do a check in PHP for whether the text box is empty before adding the data to the email?

I'm not sure what you mean by suppress. Can you do a check in PHP for whether the text box is empty before adding the data to the email?

The form has several activities which have drop down lists,

for example below, someone who wants to go cycling - if they don't want to go and don't enter any info, I don't want it to show at all on the email that is submitted from the form

<tr>
   <td>Cylcing 1:</td>
   <td>$cycling1 </td>
</tr>
<tr>
   <td>Cycling Experience 1:</td>
   <td>$cyclingEx1 </td>
</tr>
if(isset($cycling1)) {echo "<tr>
   <td>Cylcing 1:</td>
   <td>".$cycling1." </td>
</tr>
<tr>
   <td>Cycling Experience 1:</td>
   <td>".$cyclingEx1." </td>
</tr>"; }

if(isset($fasterthanaspeedingbullet1)) {echo "<tr>
   <td>fasterthanaspeedingbullet 1:</td>
   <td>".$fasterthanaspeedingbullet1." </td>
</tr>
<tr>
   <td>fasterthanaspeedingbullet 1:</td>
   <td>".$fasterthanaspeedingbulletEx1."</td>
</tr>"; }

if(isset($leaptallbuildingswithasinglebound1)) {echo "<tr>
   <td>leapingtallbuildingswithasinglebound 1:</td>
   <td>".$leaptallbuildingswithasinglebound1." </td>
</tr>
<tr>
   <td>leaptallbuildingswithasinglebound Experience 1:</td>
   <td>".$leaptallbuildingswithasingleboundEx1."</td>
</tr>"; }

if(isset($morepowerfulthanalocomotive1)) {echo "<tr>
   <td>morepowerfulthanalocomotive 1:</td>
   <td>".$morepowerfulthanalocomotive1." </td>
</tr>
<tr>
   <td>morepowerfulthanalocomotive 1:</td>
   <td>".$morepowerfulthanalocomotiveEX1."</td>
</tr>"; }
This article has been dead for over six months. Start a new discussion instead.