0

重複の可能性:
送信はjavascriptの関数ではありません
JSを使用してフォームを送信する方法

お問い合わせフォームがあり、ユーザーが [送信] をクリックすると、ダイアログ ボックスが開き、[OK] をクリックすると、フォームが送信されます。ただし、[OK] をクリックすると、ダイアログ ボックスが閉じられるだけで、フォームは送信されません。ここに行くとコードをテストできます。

Javascript/jQuery: //

function go_there(){

    $.prompt('<b>DISCLAIMER</b> <span style="font-weight:normal">TEXT WILL GO HERE</span>',{
       buttons: { Ok: true, Cancel: false}, 
       callback: function(e,v,m,f){
          if(v){

                 $('#email').submit()

          }else{

          }
       }
   });

}


//]]>  

</script>

HTML: //

<form method="post" action="nlphpmail.php" id="email">
            <input type="hidden" name="subject" id="subject" value="Feedback form" />
                <fieldset>
                    <div class="formfield">
                        <label class="text title" for="contact_who">Name</label>
                        <input type="text" class="text required" name="contact_who" id="contact_who" value="">
                    </div><!-- /.formfield -->
                    <div class="formfield">
                        <label class="text title" for="contact_sendto">Email address</label>
                        <input type="text" class="text required email" name="contact_sendto" id="contact_sendto" value="">
                    </div><!-- /.formfield -->
                    <div class="formfield">
                        <label class="text title" for="contact_phone">Phone</label>
                        <input type="text" class="text required" name="contact_phone" id="contact_phone" value="">
                    </div><!-- /.formfield -->
                    <div class="formfield">
                        <label class="text title" for="contact_message">Message</label>
                        <textarea name="contact_message" class="required" id="contact_message"></textarea>
                    </div><!-- /.formfield -->
                </fieldset>
                <div class="formfield">
  <button class="button" id="submit" value="send" type="button" name="submit" onClick="go_there();">Send</button>
                </div>
                </form>
4

1 に答える 1

0

「送信」ボタンをinput type="button"ではなく にしinput type="submit"ます。実際にフォームを送信する「OK」ボタンに onclick を追加します。また、Musa が述べたように、「submit」の id を持つものは何も設定しないでください。

于 2012-11-02T20:40:33.340 に答える