2017-05-08 59 views
1

我使用外部程序「自動駕駛儀」來基本上捕獲我的表單(對於我的營銷人員)。不過,我已經制作了一個不需要任何「行動」的表單,例如,我不希望網頁去任何地方,而是我想要#答案 - 按鈕作爲一個按鈕,進入下一個問題。 (我在下一個問題的表單之前有按鈕)。表單沒有行動 - >使用自動駕駛儀發佈

所以我的問題是,我如何去創建一個不重新加載頁面的表單,但仍然使用「action ='something'」發佈數據?

我的代碼

<form id="email-gate-form" action=""> 
    <input type="text" placeholder="FIRST NAME" name="first-name" required> 
    <input type="text" placeholder="LAST NAME" name="last-name" required> 
    <input type="text" placeholder="EMAIL" name="email" required> 
    <input type="text" placeholder="COMPANY" name="company" required> 
    <input type="submit" value="GET MY RESULTS" name="submit" id="answer-button" class="question-form-gate"> 
</form> 

一個小高峯到我的javascript

$("#answer-button").click(function(e) { 
e.preventDefault(); 
}); 

var emailGateButton = $("#email-gate .question-form-gate"); 
emailGateButton.on('click', function() { 

questionsOverlay.show(); 
TweenMax.staggerTo("#email-gate .animated", 0.25, {opacity: 0}, 0.25, "-=0.5") 
setTimeout(function(){ 
    emailGate.hide(); 
},1000) 
setTimeout(function(){ 
    questionFinal.show(); 
    TweenMax.staggerFrom("#section-final .animated", 0.25, {opacity: 0}, 0.25, "-=0.5") 
},1000) 
setTimeout(function(){ 
    questionsOverlay.hide(); 
},3000); 

}); 

不勝感激任何幫助。

回答

1
<form id="email-gate-form" method="post"> 
    <input type="text" placeholder="FIRST NAME" name="first-name" required> 
    <input type="text" placeholder="LAST NAME" name="last-name" required> 
    <input type="text" placeholder="EMAIL" name="email" required> 
    <input type="text" placeholder="COMPANY" name="company" required> 
    <input type="submit" value="GET MY RESULTS" name="submit" id="answer-button" class="question-form-gate"> 
</form> 

$("#email-gate-form").submit(function(e) { 
    e.preventDefault(); 
    process_form(); 
}); 

function process_form() { 
    var name = $("input[name=first-name]").val(); 
    console.log(name); 
    // do whatever you need to do with your varables 
}