[請求書の生成] ボタンをクリックすると、新しいウィンドウで請求書が開きます。
以下はサンプルコードです。例えば
<form name="invoice" action="inv_rec.php" method="post" id="inv" target="invoices" onsubmit="return check_counter();" >
<table>
<tr>
<td>
<label for="cusname"><strong>Customer Name* </strong></label>
<input type="text" size="20" name ="cusname" value="" id="Customername" required/>
</td>
<td>
<label for="for_place"><strong>Place</strong></label>
<input type="text" size="20" name ="for_place" value="" id="for_place" />
</td>
</tr>
........
<tr>
<td>
<input type="submit" value="Generate Invoice" name="submit" id="sub">
</td>
</tr>
</table>
</form>
<script>
var counter = 1;
function check_counter()
{
if(counter == 1)
{
alert("Please enter the product details");
return false;
}
window.open('', 'invoices', 'width=650,height=800,status=yes,resizable=yes,scrollbars=yes');
return true;
}
</script>
私の例では、ページは inv_rec.php(opens in new window) にリダイレクトされます。これには、ユーザーが印刷する必要がある mysql から取得した動的に生成されたデータが含まれています。前のウィンドウ (請求書フォームが表示されている場所、つまり、ユーザーがデータを入力して請求書を生成する) で開いているすべてのフォーム データをクリアしたいと考えています。