We have created a questionnaire using a HTML form. The form is submitted via a typical ajax call as follows:
$.ajax({
url: sendResults.attr('action') + "?ajax=true",
type: sendResults.attr('method'),
data: sendResults.serialize(),
success: confirm
});
However, we want to save a copy of the submitted form HTML to the server (not in a database) so that it may be rendered to a PDF and attached to a confirmation e-mail sent from another PHP script. This HTML should contain the 'checked' status of check-boxes and radio buttons as they have been changed by the user. There are no textareas in the form.
One method of doing this is to select the form HTML via javaScript as follows:
var html = "<html>" + document.getElementById('myForm').innerHTML + "</html>";
And then serialize and submit this HTML with the form data by changing this line:
data: sendResults.serialize() + "&answers=" + html
However, this requires the ISP to override some firewall rules for the action PHP script and this would probably not be considered good practice, and is likely a security risk!
So, given that the "normal" serialized form data is just an array of integers, is there any known way to "apply" these values to the default HTML form, which is stored on the server, to arrive at the form as submitted, so that it can be rendered to PDF and attached to an e-mail?
Thanks in advance for any help.