Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript $(';#电子邮件';).submit()不工作_Javascript_Modal Dialog - Fatal编程技术网

Javascript $(';#电子邮件';).submit()不工作

Javascript $(';#电子邮件';).submit()不工作,javascript,modal-dialog,Javascript,Modal Dialog,可能重复: 我有一个联系人表单,用户单击submit,会打开一个对话框,他们单击OK,然后表单提交。但是,当您单击“确定”时,它只会关闭对话框,而不会提交表单。 您可以通过执行以下步骤来测试代码 Javascript/jQuery: // 函数去那里(){ $.prompt('此处将显示免责声明文本'{ 按钮:{确定:真,取消:假}, 回调:函数(e,v,m,f){ 如果(v){ $('#email')。提交() }否则{ } } }); } //]]> HTML:// <for

可能重复:

我有一个联系人表单,用户单击submit,会打开一个对话框,他们单击OK,然后表单提交。但是,当您单击“确定”时,它只会关闭对话框,而不会提交表单。 您可以通过执行以下步骤来测试代码

Javascript/jQuery: //
函数去那里(){
$.prompt('此处将显示免责声明文本'{
按钮:{确定:真,取消:假},
回调:函数(e,v,m,f){
如果(v){
$('#email')。提交()
}否则{
}
}
});
}
//]]>  
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>

名称
电子邮件地址
电话
消息
发送

将“提交”按钮设置为
input type=“button”
而不是
input type=“Submit”
。将onclick添加到实际提交表单的“OK”按钮。此外,正如穆萨所提到的,不要设置任何id为“提交”的内容.

类似地,提交按钮
#submit
覆盖了提交功能。@Trisha我认为@Musa通过该帖子的建议是更改提交按钮的
名称和
id
。@KevinBoucher是正确的,如果您打算通过JavaScript提交,则没有任何带有name或id的表单元素
submit
提交功能。谢谢,这确实解决了一个问题。。现在,当它提交表单时,它将指向实际的nlphpmail.php并加载错误“此页面无法直接访问”@MusaThere是一个
$。提示符
未定义错误本-这有帮助,但是-现在单击“确定”时,它加载nlphpmail.php,但不发送表单。它转到表单错误“无法直接访问”“无法直接访问”似乎是目标页面的问题,而不是我们正在讨论的页面的问题。您确定要链接到那里,而不是某个派生地址吗?此外,您可能需要检查跨浏览器兼容性。我在Chrome和IE中看到了两种不同的错误行为。Ben,它应该指向那个页面。如果需要,我可以发布该页面的PHP代码,如果它有助于发现问题的话。至于错误行为,它们是什么?jsfiddle with nlphpmail.php代码错误行为:IE反复抱怨没有定义JQuery。当您开始键入时,Chrome会保留默认的灰色文本,并且只在其下方键入。至于另一个,请自己测试—您可以通过在地址栏中键入地址直接访问nlphpmail.php页面吗?
<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>