Javascript 使用codeigniter中的值打印表单数据的功能
我使用codeigniter创建了一个包含多个表单的页面。我想显示一个弹出窗口,用于打印表单中的数据,该窗口中有一个打印按钮。但是我不知道如何以它的形式获取数据,直到在codeigniter中打印的退出弹出窗口。你能帮我为这个问题编码吗。老实说,我从来没有犯过错误编码喜欢这个问题,因为我也是初学者。所以你是初学者,很好。这里你有一些想法可以尝试。此解决方案使用jQuery获取服务器数据,将其放入动态创建的iframe中,并打印出对CI、WP有用的数据。这就是你想要的,嗯 1.-jquery的东西Javascript 使用codeigniter中的值打印表单数据的功能,javascript,codeigniter,printing,Javascript,Codeigniter,Printing,我使用codeigniter创建了一个包含多个表单的页面。我想显示一个弹出窗口,用于打印表单中的数据,该窗口中有一个打印按钮。但是我不知道如何以它的形式获取数据,直到在codeigniter中打印的退出弹出窗口。你能帮我为这个问题编码吗。老实说,我从来没有犯过错误编码喜欢这个问题,因为我也是初学者。所以你是初学者,很好。这里你有一些想法可以尝试。此解决方案使用jQuery获取服务器数据,将其放入动态创建的iframe中,并打印出对CI、WP有用的数据。这就是你想要的,嗯 1.-jquery的
// <input type="button" id="print_me" data-form_id="101">
$("#print_me").live("click", function() {
var form_id = $(this).data("form_id"); // get value 101
$.post(
// url to server where you get data to print
window.location.href,
{
// vars sent to server to get data to print
form_id : form_id // send form_id=101
// etc
},
// output.contents have content to print
function(output) {
// create iframe
var ifrm = document.createElement("iframe");
ifrm.style.display = "none";
document.body.appendChild(ifrm);
setTimeout(function() {
// put content into the inframe
$(ifrm).contents().find("body").html(output.contents);
}, 1);
// print when iframe is loaded
ifrm.onload = function() {
ifrm.contentWindow.print();
}
}, 'html');
});
你必须深入调查每一个步骤。一旦你实现了目标,你就会学到很多。祝你好运
$form_id = $_REQUEST['form_id']; // here we receive our data
ob_start();
// echo HTML formatted data to print
$contents = ob_get_contents(); // $contents store all echoed HTML
ob_end_clean();
$output['contents'] = $contents; // wrap in $output
echo json_encode($output); // echo json encoded data
exit; // you must exit here!