I have a form with the following code in a php file:
<select id="choice" name="choice" class="ddl" style="width: 121px">
<?php
foreach($xml->children() as $pizza){
?>
<option value="<?php echo $pizza; ?>" selected=""><?php echo $pizza; ?></option>
<?php }?>
and the following Jquery code
$("#addbt").click(function () {
$('#choice').clone()
.attr('id', 'choice' + $('.ddl').length)
.attr('name', 'choice' + $('.ddl').length)
.insertAfter(".ddl:last"); });
I need to send the data in the form (Other data isn’t a problem) of an email. The form has an add button that creates new drop down lists with different names (choices, choices1, choices2 and so on depending on how much the button was clicked).
The mail.php where the info is send is:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$choice = $_POST['choice'];
$phone= $_POST['phone'];
$town= $_POST['town'];
$formcontent="
Name: $name \n
Number: $phone \n
Choice: $choice \n
Town: $town \n
Email: $email" ;
$recipient = "courses@os4u.eu";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
I don’t know how to add the new choices (choices1, chocies2..etc) into the form in a functional way.
You can loop through the post values:
Then add the contents of $options to you mail body.
Just a quick solution..
Be aware, all post elements will be added to the body this way..