将表单提交到颜色框Iframe

Submit Form to a Colorbox Iframe

本文关键字:Iframe 颜色 表单提交      更新时间:2023-09-26

我正试图将此表单提交到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/