1

以下のコードは、お問い合わせフォームの送信ボタンでポップアップを開こうとしています

<form id="contact" name="contact" method="post" action="mail2.php" onsubmit="return valid();">
            <label>Name :</label>
                <input name="name" type="text" id="name" class="contact-input-box" />

            <label>Contact No. :</label>
                <input name="telephone" type="text" id="telephone" class="contact-input-box" />

            <label>Email :</label>
                <input name="email" type="text" id="email" class="contact-input-box" /><br class="clearBoth" />  

            <label>Gender :</label>
            <span>Mail</span> <input type="radio" name="gender" value="male">
            <span>Femail</span> <input type="radio" name="gender" value="female" /> <br class="clearBoth" />

            <label>product :</label>
            <select name="product" class="dropdown" id="product">
                      <option>Product</option>
                      <option value="cd">CD</option>
                      <option value="dvd">DVD</option>
            </select> <br class="clearBoth" />

            <label>Comment :</label>
                <textarea name="comment"  id="comment" class="contact-input-box1"></textarea><br class="clearBoth" />
                <p id="button1"></p>

            <label>&nbsp;</label>
                <input name="button" type="submit" id="button" title="Submit" value="Submit" onclick="myFunction()" /> 
        </form>

しかし、ポップアップを開くことができません。フォームは正常に機能しています。現在、thankyou.html ページに掲載されています。ポップアップボックスでお礼のメッセージを開く必要があります。

4

5 に答える 5

1

JqueryUi ダイアログを試してください。このようにして、カスタマイズ可能なポップアップで de thankyou.html を表示できます。

問題を解決する簡単な方法です。

于 2013-04-19T13:00:16.757 に答える
0

試す

  $('#button').submit(function() {
      alert('Handler for .submit() called.'); //you can call myFunction()  here
      return false  //will stop the form submission.

    });

フォームの送信を停止したくない場合は、ページが既に送信されているため、アラートを表示する必要はありません。

またはsetTimeout、しばらくの間、Thankyou のポップアップを表示してから、フォームを送信してみてください。

于 2013-04-19T12:26:09.700 に答える
0

フォームを送信するかどうかをユーザーに尋ねるポップアップが必要な場合は、フォームの onsumbit イベントにフックできます。

function beforeSubmit() {
    if (confirm("Are you sure, you want to submit form?")) {
        return true;
    } 
    return false;
}

サンプルデモ

于 2013-04-19T12:58:11.273 に答える