I have the following form:
<form action="" method="POST" name="form" id="form">
<input name="year" type="text" id="year" placeholder="YYYY" size="4" maxlength="4">
<input name="month" type="text" id="month" placeholder="MM" size="2" maxlength="2">
<input name="day" type="text" id="day" placeholder="DD" size="2" maxlength="2">
<input name="hour" type="text" id="hour" placeholder="HH" size="2" maxlength="2">
<input name="minutes" type="text" id="minutes" placeholder="MM" size="2" maxlength="2">
<input name="seconds" type="text" id="seconds" placeholder="SS" size="2" maxlength="2">
<input name="sampleduration" type="text" id="sampleduration" size="4" maxlength="4">
<input type="hidden" name="sample" id="sample">
<input type="submit" name="submit" id="submit" value="Mark as reviewed">
</form>
Prior to submission of the form, I would like to concatenate some of the form fields and submit them as a string.
The string should look something like this: "2014-12-03 23:43:12"
The string is a concatenation of the individual form fields above.
I created a hidden form field "sample" so that I can assign the concatenated string to the hidden form field prior to form submission.
After form submission, php/mysql take over and insert the form into a mysql database.
The jQuery code that I have looks like this:
<script>
$( "#form" ).submit(function( event ) {
$('#sample').val(year+'-'+month+'-'+day+' '+hour+':'+minutes+':'+seconds); });
</script>
My jQuery code does not work. Can anyone explain why?
year,month, etc.event.preventDefault()as first line in your function.