I have this form that creates a input field dynamically, only problem is, the input field doesn’t pass the values to the php script. Im assuming i need to either code the javascript to populate the variable in the php script or vice versa im stuck on this??? any ideas the cript is below:
Php script:
[code=php]
<?php
$EmailTo = “[email protected]”;
$Youngest = Trim(stripslashes($_POST[‘names[]’]));
// prepare email body text
$Body .= “Extra names: “;
$Body .= $Youngest;
$Body .= “n”;
// send email
$success = mail($EmailTo, $Body);
// redirect to success page
if ($success){
print “<meta http-equiv=”refresh” content=”0;URL=ok.htm”>”;
}
else{
print “<meta http-equiv=”refresh” content=”0;URL=error.htm”>”;
}
?>
the form is:
[code]
<form action=”cgi/guestlistForm.php” method=”post”>
<div id=”firstname”>
<p>
<label for=”name_3″ title=”guests”>+ Guests full name :</label>
<input class=”inputField” type=”text” name=”names[]” id=”name_3″>
</p>
</div>
<div>
<p><a href=”javascript://” id=”addperson”>+ Add another guests</a></p>
<script type=”text/javascript”>
var count = 2; // The one that’s already there is 1
Event.observe(‘addperson’, ‘click’, function() {
count++
var namefield = ‘<div id=”firstname”><p><label for=”name_’+count+'” guests”>Full name:</label><input class=”inputField” name=”names[]” type=”text” id=”name_’+count+'” /></p></div>’;
new Insertion.Bottom(‘firstname’, namefield)
});
</script>
</div>
<input class=”submit” name=”image” id=”image” type=”image” onmouseover=”src=’images/submit_over.gif'”onmouseout=”src=’images/submit.gif'” value=”Send” src=”images/submit.gif”/>
</div>
</form>