Hi guys,
I have a form that has some jquery added to it so that my user can add new rows of date by adding more form fields. Here is the script:
<?php
ob_start();
include('connect.php');
$hID = $_REQUEST['ID'];
$hname = $_REQUEST['name'];
?>
<head>
<script language="Javascript" src="jquery.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
var current = 1;
function addEntry() {
current++;
var strToAdd = '<tr><td><p><input id="eracedated'+current+'" name="eracedated'+current+'" size="5" /> <input id="eracedatem'+current+'" name="eracedatem'+current+'" size="5" /> <input id="eracetime'+current+'" name="eracetime'+current+'" size="5" /> <input id="eracetype'+current+'" name="eracetype'+current+'" size="15" /> <input id="eraceage'+current+'" name="eraceage'+current+'" size="5" /> <input id="eentdated'+current+'" name="eentdated'+current+'" size="5" /> <input id="eentdatem'+current+'" name="eentdatem'+current+'" size="5" /> <input id="eracetrack'+current+'" name="eracetrack'+current+'" size="15" /> <input id="eracedistance'+current+'" name="eracedistance'+current+'" size="5" /> <input type="hidden" id="ehid'+current+'" name="ehid'+current+'" value="<?php echo $hID; ?>" /><input type="hidden" id="ehorse'+current+'" name="ehorse'+current+'" value="<?php echo $hname; ?>" /></p></td></tr>'
$('#mainField').append(strToAdd)
}
$(document).ready(function(){
$('#addEntry').click(addEntry)
});
</script>
</head>
<style type="text/css">
body { background-color:#4a0303; }
</style>
<div style="background-color:#734e4e; border:2px solid #000000; color:#FFFFFF; padding:10px; width:770px;">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
<fieldset style="border:none;" id="mainField">
<p>
<input id="eracedated1" name="eracedated1" size="5" />
<input id="eracedatem1" name="eracedatem1" size="5" />
<input id="eracetime1" name="eracetime1" size="8" />
<input id="eracetype1" name="eracetype1" size="15" />
<input id="eraceage1" name="eraceage1" size="5" />
<input id="eentdated1" name="eentdated1" size="8" />
<input id="eentdatem1" name="eentdatem1" size="8" />
<input id="eracetrack1" name="eracetrack1" size="15" />
<input id="eracedistance1" name="eracedistance1" size="5" />
<input type="hidden" id="ehid1" name="ehid1" value="<?php echo $hID; ?>" />
<input type="hidden" id="ehorse1" name="ehorse1" value="<?php echo $hname; ?>" />
</p>
</fieldset>
</td>
</tr>
<tr>
<td>
<p>
<input type="button" id="addEntry" value="Add Another Entry">
</p>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Upload Entries"> <input type="submit" name="cancel" onclick="window.parent.location.href=window.parent.location.href;" value="Cancel" />
</td>
</tr>
</table>
</form>
</div>
If my user clicks the addentry button a new set of fields will appear so that they can add another row. Now comes the tricky part, how the hell do I process this with PHP to add each line as a record into my database?
It really is stumping me on how to do it. Any help, as always, is very much appreciated.
Kind regards