2017-01-23 50 views
0

我正在使用jQuery步驟插件的一種形式,我試圖做這樣的事情:我有一個完整的表單,我想顯示一個根據對問題的初始反應進行的或另一個步驟。如何根據初始響應顯示錶單步驟(jquery步驟)

最初的問題是這樣的:

<div id="initial_question" style=" z-index: 10000;text-align: center; padding-top: 200px;position: fixed; top: 0%;left: 0%;right: 0%;bottom: 0%; background-color: rgba(178,139,8,1)"> 
      <div class="middle-box text-center animated fadeInDown"> 

       <h3 class="font-bold">¿question?</h3> 

       <div > 

        <a id="yes"class="btn btn-primary m-t">yes</a> 
        <a id="not" class="btn btn-primary m-t">not</a> 
       </div> 
      </div> 
     </div> 

我的形式是這樣的:

<form id="form" enctype="multipart/form-data" method="POST" class="wizard-big"> 

    <h1>Applicant details</h1> 
    <fieldset> 
<!--.........--> 
    </fieldset> 
    <h1 class="option_no">Owner's data</h1> 
    <fieldset class="option_no"> 
<!--.........--> 
    </fielset> 
</form> 

我試圖讓一個刪除,我做了形式的步驟元素的腳本不想展示,但我沒有得到它的工作。該腳本如下:

<script> 

     $(document).ready(function(){ 


      $("#yes").click(function() { 
      $("#initial_question").fadeOut("slow"); 
      }); 


      $("#not").click(function() { 

      $(".option_no").remove(); 

      $("#initial_question").fadeOut("slow"); 

      }); 
} 
</script> 

PS:我大概有沒有把整個表單錯字的錯誤,但在本質上,這就是我要舉例說明我的問題。

回答

0

你看了一下switch/case語句嗎?

switch (n) { 
case label1: 
// code to execute if answer is yes; 
break; 

case label2: 
// code to execute if answer is no; 
break; 
default: 
echo "Please choose yes or no"; 
break; 
} 
+0

問題是代碼在每種情況下執行。你的代碼符合我的代碼的相同目標。 – Mvram