我有一个类似于下面的HTML表单:
<div id="print">
<h2>I am header</h2>
Name : <input type="text" />
College : B Borooah College
<select>
<option>Student</option>
<option>Staff</option>
</select>
<div>
<input type="button" value="PRINT" onclick="PrintContent()" />
还有一个javascript
函数可以使用#print
打印内容:
function PrintContent()
{
var DocumentContainer = document.getElementById('print');
var WindowObject = window.open('', 'PrintWindow', 'width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes');
WindowObject.document.writeln('<!DOCTYPE html>');
WindowObject.document.writeln('<html><head><title></title>');
WindowObject.document.writeln('</head><body>')
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.writeln('</body></html>');
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
当我点击print
按钮时,它会打印默认表单,而不是我添加name
feld或更改select drop down
的表单。如何打印输入/更改的值?
答案 0 :(得分:1)