I try to create a screenshot from a form when submitting with html2canvas. I use this code:
//Create Screen
var element = $("#formmain");
var getCanvas;
html2canvas(document.querySelector("#formmain")).then(canvas => {
document.body.appendChild(canvas),
save_img(canvas.toDataURL('image/jpeg'))
});
save_img function:
function save_img(data){
//ajax method.
$.post('save_screen.php', {data: data}, function(res){
//if the file saved properly, trigger a popup to the user.
if(res != ''){
yes = confirm('File saved in output folder, click ok to see it!');
if(yes){
location.href =document.URL+'temp/'+res+'.jpg';
}
}
else{
alert('something wrong');
}
});
}
It is creating a screenshot but the input form fields are allways empty in screens.