0

[請求書の生成] ボタンをクリックすると、新しいウィンドウで請求書が開きます。

以下はサンプルコードです。例えば

    <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*&nbsp;</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 から取得した動的に生成されたデータが含まれています。前のウィンドウ (請求書フォームが表示されている場所、つまり、ユーザーがデータを入力して請求書を生成する) で開いているすべてのフォーム データをクリアしたいと考えています。

4

4 に答える 4

2

フォームの送信後にページをリダイレクトします。

header('location:redirect.php');

またはフォームの変数を設定解除します

Jquery の場合:

$('#form_id')[0].reset();

于 2013-07-01T11:51:19.777 に答える
0

あなたの質問はあまりにも明確ではありませんか?別の新しい入力セットの準備ができるように、フォーム フィールドをクリアしていますか? その場合は、java スクリプトで window.open() メソッドを呼び出す直前に reset を呼び出すことができます。このようなもの:

<script>
var counter = 1;
function check_counter()
{
 if(counter == 1)
   {
      alert("Please enter the product details");
       return false;
    }
  $('#formid).reset();  //assuming you are using jquery
 window.open('', 'invoices','width=650,height=800,status=yes,resizable=yes,scrollbars=yes');

return true;
}
</script>
于 2013-07-15T08:54:52.837 に答える
0

誰かが JavaScript を無効にしてフォームを POST する可能性があるため、JS に頼ってクリーニングを行うのは安全ではないと思います。

post/redirect/get patternを調べることをお勧めします。

于 2013-07-01T11:51:49.840 に答える
0

これを実現するには、javascript または jquery のいずれかを使用できます。

JavaScriptで

document.getElementByName("invoice").reset();

jqueryで

$("#formId").reset();

これを使用するにはフォームにIDを追加してください

<form name="invoice" id="invoice" action="generate_invoice.php" method="post" target="_blank">
于 2013-07-01T11:45:44.487 に答える