Hi,
How would I adapt my code to accomodate a file upload from my form?
Here’s my code
<script type="text/JavaScript">
/* attach a submit handler to the form */
$(document).ready(function(){
$("#contractdiary").submit(function(event){
/* stop form from submitting normally */
event.preventDefault();
/* get some values from elements on the page: */
var $form = $(this),
AddEvent = $form.find('input[name="addevent"]').val(),
EntryType = $form.find('select[name="entry_type"]').val(),
Title = $form.find('input[name="title"]').val(),
ThisDate = $form.find('input[name="date"]').val(),
City = $form.find('input[name="city"]').val(),
Postcode = $form.find('input[name="postcode"]').val(),
JobRef = $form.find('input[name="job_reference"]').val(),
StartDate = $form.find('input[name="start_date"]').val(),
EndDate = $form.find('input[name="end_date"]').val(),
Rate = $form.find('input[name="rate"]').val(),
Employer = $form.find('input[name="employer"]').val(),
Notes = $form.find('textarea[name="notes"]').val(),
url = $form.attr('action');
/* Send the data using post and put the results in a div */
$.post(url, {
add_event: AddEvent,
entry_type: EntryType,
title: Title,
date: ThisDate,
city: City,
postcode: Postcode,
job_reference: JobRef,
start_date: StartDate,
end_date: EndDate,
rate: Rate,
employer: Employer,
notes: Notes,
secureuri:false,
fileElementId:'doc',
dataType: 'json'
},
function(data) {
$("#diaryresult").empty().append(data);
}
);
});
});
</script>