これにはjQueryを使用していますが、現在は使用できません(理由はありません)。テーブルの一部を選択して印刷する必要があります。
私はこのコードを使用します:
function Printon(this)
{
newWin= window.open('','','toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=800, height=1000, left=10, top=25');
newWin.document.write('<table>' + document.getElementsByName(this).innerHTML + '</table>');
newWin.document.close();
newWin.focus();
newWin.print();
newWin.close();
return false;
}
次に、名前のパラメーターを使用して関数を呼び出すと、<tr>
次のドキュメントを取得します。
12-11-12
undefined
私のHTMLは正しいと確信していますが、それでも私のHTMLは次のとおりです。
<tr name="Print_1">
<td>dhr Kees-jan ckc Von fleppenstein</td>
<td>aquaduct straat 66<br>0606 OP ORK</td>
<td>WDB-1352303696</td>
<td>2822.00</td>
<td><input type="button" value="Print this" onclick="Printon('Print_1')"></td>
<td> </td>
</tr>
<tr name="Print_1">
<td>-</td>
<td> </td>
<td> </td>
<td>46.00</td>
<td>2</td>
<td>Actiesalade herfst</td>
</tr>
<tr name="Print_1">
<td>-</td>
<td> </td>
<td> </td>
<td>46.00</td>
<td>2</td>
<td>Actiesalade herfst</td>
</tr>
@Muthu Kumaran のインスピレーションで、私はこれを使用します:
function Printon(dit)
{
var arr = new Array();
arr = document.getElementsByName(dit);
var tabel = '';
for(var i = 0; i < arr.length; i++){
tabel += document.getElementsByName(dit)[i].outerHTML;
}
newWin= window.open('','','toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=800, height=1000, left=10, top=25');
newWin.document.write('<table border=\"2\" cellpadding=\"2\" cellspacing=\"0\">' + tabel + '</table>');
newWin.document.close();
newWin.focus();
newWin.print();
newWin.close();
return false;
}
修正されて動作するようになりました!