Tag: forms

提交前jQuery表单发布

我有一个页面,上面有一个需要发布到外部URL的表单。 但是,我还需要将此信息发送到当前页面(mypage.php)。 出于安全原因,我不能只发布到mypage.php并使用cURL通过PHP发布到外部网站 – 表单必须直接提交到外部网站。 这段代码可以在mypage.php上找到并且不起作用(我假设myform的提交不等待post): $(‘#myform’).submit(function() { $.post(‘mypage.php’, serialized_form, function(data) { … }, ‘html’ ); } … … 做这样的事情的最佳方法是什么? 谢谢!

使用jquery以嵌套forms提交子表单

我有一个嵌套的forms,看起来像: <FORM METHOD="GET" NAME="mainForm" ACTION=> Tab3 儿童forms代码: <FORM METHOD="GET" NAME="childForm" id = "childForm" ACTION=> Process Child Form 当我点击submitChildForm按钮时,我想提交子表单,所以我写了下面的jquery处理程序来做到这一点: $(‘.submitChildFormClass’).live(‘click’,function() { document.getElementById(“previewOnlyVal”).value = “previewOnly”; $(‘#childForm’).submit(); }); 问题是,当我点击按钮时,MAIN FORM将被提交,而不是子表单。 我知道使用嵌套表单不是一个好的编程习惯,但这是一个旧代码,我们还没有太多时间来修改这些代码。 任何人都可以告诉我在代码中可能缺少什么导致主要表单由jquery提交? 在此先感谢您的帮助。

event.preventDefault(); 不工作

我正在尝试提交表单而不刷新页面,但是event.preventDefault(); 不工作。 这是我到目前为止所拥有的 $(‘#contactform’).on(‘submit’, function() { event.preventDefault(); var that = $(this), url = that.attr(‘action’), type = that.attr(‘method’), data = {}; that.find(‘[name]’).each(function(index, value) { var that = $(this), name = that.attr(‘name’), value = that.val(); data[name] = value; }); $.ajax({ url: url, type: type, data: data, succss: function(response) { console.log(response); } }); }); 但是,一旦按下提交按钮,页面仍会重新加载。 有什么建议? 更新:主表单页面的代码如下; <script […]

Formspree:Ajax提交无法正常工作

我在我的页面上使用formspree作为单字段表单。 为了避免将我的用户重定向到默认的感谢页面,我正在尝试使用ajax提交表单并显示成功/错误消息。 但是,我的代码不起作用。 据我所知,消息不会出现。 我认为这与想要在我的按钮中显示的消息有关,而我的按钮是输入字段。 这是小提琴 ,这是代码: HTML: JS: var contactForm = document.querySelector(‘#contact-form’), inputName = contactForm.querySelector(‘[name=”name”]’), sendButton = contactForm.querySelector(‘#send-button’); sendButton.addEventListener(‘click’, function(event){ event.preventDefault(); // prevent the form to do the post. sendButton.innerHTML = ‘Sending..’; var xhr = new XMLHttpRequest(); xhr.open(‘POST’, ‘//formspree.io/myemail@gmail.com’, true); xhr.setRequestHeader(“Accept”, “application/json”) xhr.setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded”) xhr.send( “name=” + inputName.value; xhr.onloadend = function (res) { if […]

jquery倒计时 – 到期时自动提交表格?

我正在使用jquery_countdown(http://keith-wood.name/countdown.html)来设置60分钟的计时器。 我知道我可以在时间到期时运行回调函数,但有没有办法自动提交表单? 我尝试了以下内容,但未能提交(尽管firebug控制台中没有错误): jquery_countdown_add ( “.countdown”, array ( “until” => 10, “onExpiry” => “finished” ) ); function finished() { $(‘#formsamp’).submit(function(){return true;}); }

从alertify插件和jquery确认框返回值

我的表格有一个确认对话框。 它在jquery提交函数中。 我正在使用alertify来显示确认对话框。 但问题是我的jquery提交函数在alertify获取确认框值之前返回。 读取alertify是非阻止的。 有什么方法可以解决这个问题并将确认框值返回给我的表单? $(“#viewform”).submit(function(){ alertify.confirm(“Delete the selected entry?”,function(e){ if(e) return true; else return false; }); }); 该函数始终返回true。 我想返回确认框的输出。 如何返回确认框的延迟返回值?

不可见的reCAPTCHA以多种forms发送空的g-recaptcha-response

我正在尝试使用Google Invisible reCAPTCHA ,但是当我在同一页面中有多个表单时,它会发送空的g-recaptcha-response POST参数。 这是我的代码: 谷歌JS 表格1 Send 表格2 Send 我的JS (基于这个答案 ) $(document).ready(function() { window.captchaCallback = function(){ $(‘.g-recaptcha’).each(function(index, el) { var attributes = { ‘sitekey’ : $(el).data(‘sitekey’), ‘size’ : $(el).data(‘size’), ‘callback’ : $(el).data(‘callback’) }; grecaptcha.render(el, attributes); }); }; window.form1Callback = function(){ $(‘#form1’).submit(); }; window.form2Callback = function(){ $(‘#form2’).submit(); }; }); 当我提交其中一个表格时, g-recaptcha-response参数将被发送为空,如下所示。 有人可以帮我把它投入使用吗?

如何使用jquery检查select元素是否仍处于“打开”/活动状态

无论如何,我可以通过jQuery检测到当前选择的表单元素是否处于活动状态? 我创建了这个小提琴来演示这个问题: http://jsfiddle.net/E2PhT/2/ 当您将鼠标hover在“搜索”-Link上时,搜索表单会显示出来。 当您现在单击选择字段以打开内部选项,然后在不选择任何内容的情况下,将表单保留在右侧(将鼠标移动到灰色块的右边缘),选择字段保持打开状态eles消失(应该如此)。 现在我想要使select元素再次处于非活动状态,因此只要select元素仍处于打开状态,它就不会保持打开状态或阻止表单的其余部分消失。 所以无论哪种方式,我都必须以某种方式检测选择字段是否仍处于打开或活动状态。 有没有办法用jQuery检查这个状态? 谢谢你的帮助。

在提交表单后如何使用jQuery或Ajax交换背景图像?

我有一个使用背景图像的标准html表单。 在用户点击提交按钮后,我想用确认图像替换整个表单,但是我对jQuery或Ajax不够精明。 你可以在左上方看到表格。 这是html: Private Commercial 这是css: #freeQuote { width: 231px; height: 267px; background-image: url(../_images/free-quote.png); } #freeQuote form { padding-top: 70px; } #freeQuote input { border: 1px solid #666; margin-left: 20px; width: 200px; } #freeQuote select { width: 200px;margin: 5px 0 10px 22px; } input#quoteSubmit { width: 208ox; border: none; } 我想用这张图片替换整个表格:_images / free-quote-confirm.png 任何帮助整理这个将非常感谢并立即得到承认。 […]

jquery Dynamicaly克隆字段和增量id

如何克隆此块并增加标题号,如果可能的话增加ID? 对于每个div“block-1”我想要添加和删除选项。 提前致谢 title 1 First Name* Last Name* Middle Initial* Social Security #* Foreign Address* Yes No Address line 1* Address line 2* City * Email * Date of Birth * Home Phone* Gender *