Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery在提交表单后打印_Javascript_Jquery_Css_Html - Fatal编程技术网

Javascript Jquery在提交表单后打印

Javascript Jquery在提交表单后打印,javascript,jquery,css,html,Javascript,Jquery,Css,Html,我想使用jquery打印,这里有一个按钮来执行这个taxk,但我想在表单提交后打印它 这是我在按钮点击事件中打印内容的代码,打印后ti将提交表单。。我该怎么做 Ok 函数printDiv(divName){ //警报; var printContents=''; var输入,指数; inputs=document.querySelectorAll('input,select'); 打印内容+=“” 打印内容+=''; w=window.open(); w、 文件。书写(打印内容); w、 打印

我想使用jquery打印,这里有一个按钮来执行这个taxk,但我想在表单提交后打印它

这是我在按钮点击事件中打印内容的代码,打印后ti将提交表单。。我该怎么做

Ok
函数printDiv(divName){
//警报;
var printContents='';
var输入,指数;
inputs=document.querySelectorAll('input,select');
打印内容+=“”
打印内容+='';
w=window.open();
w、 文件。书写(打印内容);
w、 打印();
w、 close();
}

提交作业后无法打印任何内容,您可能需要将数据发送到后端并存储,然后检索。使用会话范围变量等。

您可以通过两种方式完成

1-可以使用


2-您可以使用jquery隐藏元素并在表单提交之前完成打印

在后端成功响应后,我如何打印发票,如下所示:

var mywindow = window.open('_blank', '', '');
mywindow.document.write('<html><head></head><body onload="setTimeout(myFunction(){window.print();}, 3000)">');  
var printContents = '<style>@media print {  .print_hide{display: none;} } </style>';
printContents += '<div id="print-content"><form><table width="100%" height="100"><tbody>';
var inputs, index; inputs = document.querySelectorAll('input,select'); 
printContents+='<div style="width:765px; float:left; height:72px;">';
printContents +='</tbody></table>';
mywindow.document.write(printContents);
mywindow.document.write('</body></html>');                        
mywindow.document.close();
var mywindow=window.open(“空白”、“空白”);
mywindow.document.write(“”);
var printContents='@media print{.print_hide{display:none;}}';
打印内容+='';
var输入,指数;inputs=document.querySelectorAll('input,select');
打印内容+='';
打印内容+='';
mywindow.document.write(打印内容);
mywindow.document.write(“”);
mywindow.document.close();

它将打开一个新窗口…

打印位置?在控制台上?还是在用户界面上?你想在提交前停止屏幕吗?是的,我想在提交前停止屏幕如果提交完成,那么它将被打印如果在提交过程中出现任何问题,如验证和所有问题,那么它将不会打印Hey@Gulshan它怎么能工作我不能这样做bcoz这个按钮与我的表单提交有关Hey我也不想在这个页面中打印所有内容我使用选定的输入进行打印对于特定内容打印使用带有“.print_hide”类的CSS并应用于被忽略的内容…..同时在CSSi中添加@media print{.print_hide{display:none;}}无法理解您想要说什么Var printContents='';var输入,指数;inputs=document.querySelectorAll('input,select');打印内容+='';打印内容+='';因为我写css也会听到页面上的每个值