Reputation: 1154
I have one functionality to get the print of current page. So to prepare the content, I am showing everything on one popup up first then later a print popup and then print command.
Trying to do the same with below code.
$('#button').on('click',function() {
var popup = window.open("","mypopup","width=500,height=300");
var html = $("#form").html();
$(popup.document.body).html(html);
popup.print();
});
Tried with clone() method as well but not working.
So the issue is, I am not getting the element's values in my popup.
Thanks
Upvotes: 0
Views: 1970
Reputation: 235
HI Use simple jquery line for each input field.
You can add a value attribute for your input fields.
I have changed your script a bit. Please refer it.
$('#button').on('click',function() {
var popup = window.open("","mypopup","width=500,height=300");
// I am setting the value attribute in the html . Do this for all fields
// with similar input fields you can have a jQuery('input').each(); loop
$('#name').attr('value',$('#name').val());
var html = $("#form").html();
$(popup.document.body).html(html);
popup.print();
});
Upvotes: 3
Reputation: 99
Manually send the data from form through ajax call and store it in a local websql (browser)storage which can be retrived in the print preview dialog box
Upvotes: 0