繁体   English   中英

将表单提交到Colorbox iframe

[英]Submit Form to a Colorbox Iframe

我正在尝试将此表单提交到Colorbox iframe。 任何使它起作用的想法...价值没有传递

<form action="newsletter/add.php" method="GET" onSubmit='$.colorbox({width:"90%", height:"60%", iframe:true, href:"newsletter/add.php"}); return false;'>
<input name="name" type="text" placeholder="Nombre">
<input name="email" type="text" placeholder="Email">
<input name="cellphone" type="text" placeholder="Celular">
<input type="submit" name="submit" id="submit" value="SUSCRIBIR" />
</form>

这是处理onSubmit事件所需的条件:

$.colorbox({width:"90%", height:"60%", iframe:true, href:"newsletter/add.php&" + $(this).serialize()}); return false;

请记住,将事件处理程序直接附加到HTML元素不是最佳实践。 您可以通过执行以下操作来改进此代码:

$(document).ready(function(){
  $(form).on('submit', function(event) {
    $.colorbox({width:"90%", height:"60%", iframe:true, href:"newsletter/add.php&" + $(this).serialize()}); 
    event.preventDefault();
  });
});

演示: http//jsfiddle.net/pottersky/xeL5bm2e/1/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM