2015-11-26 53 views
0

我試圖將此表單提交給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> 
+2

什麼是你面臨的問題是什麼呢?任何錯誤? –

+0

沒有錯誤,\t表單值是不傳遞的,有什麼想法? – paisapimp

回答

0

在這裏工作,請...值不經過您需要處理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/

+0

嗨,謝謝你的回覆,表單的值不是通過任何想法? – paisapimp

+0

我認爲不可能做到這一點。你需要一個解決方法。例如,在提交時,閱讀表單值並連接到'href'字符串。 –