如何根据初始响应显示表单步骤(Jquery步骤)
我正在使用jquery步骤插件的一种形式,我正在尝试这样做:我有一个完整的表单,我想根据对一个问题的初始回答显示一个或另一个步骤 最初的问题是这样的:如何根据初始响应显示表单步骤(Jquery步骤),jquery,html,forms,jquery-steps,Jquery,Html,Forms,Jquery Steps,我正在使用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
<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>
什么问题?
对
不
我的表格是这样的:
<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>
$(文档).ready(函数(){
$(“#是”)。单击(函数(){
$(“初始问题”)。淡出(“缓慢”);
});
$(“#非”)。单击(函数(){
$(“.option_no”).remove();
$(“初始问题”)。淡出(“缓慢”);
});
}
PS:我可能因为没有填写整个表单而有打字错误,但本质上这就是我需要举例说明的问题。你看过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;
}
问题是在每种情况下要执行的代码。您的代码满足与我的代码相同的目标。