将开机自检与多步骤表单一起使用时出现问题
Problems using POST with a Multi Step Form
>我有一个 3 阶段表单,用户可以在其中输入数据,我想使用 POST 命令,以便数据可以在另一个页面上使用。使用单个表单时,POST工作正常,如下所示
<form action="otherpage.php" method="post">
Question: <input type="text" name="something" /><br />
<input type="submit" name="submit" value="Submit me!" />
</form>
但是现在,我有一个 3 阶段表单,用户在每个阶段输入一些数据。屏幕过渡使用 jquery,除了使用 POST 之外,每个人似乎都可以正常工作。
<form id="msform" action="otherpage.php" method="post">
<!-- progressbar -->
<ul id="progressbar">
<li class="active">Screen1</li>
<li>Screen2</li>
<li>Screen3</li>
</ul>
<!-- fieldsets -->
<fieldset>
<h2 class="fs-title">Title</h2>
<h3 class="fs-subtitle">Question?</h3>
<input type="text" name="variable1" placeholder="blah" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Student Status</h2>
<h3 class="fs-subtitle">Are you are student?</h3>
<input type="radio" name="student" value="yes" checked>Yes
<input type="radio" name="student" value="no">No
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Dropdown</h2>
<h3 class="fs-subtitle">Dropdown Question?</h3>
<select name="mydropdown">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="submit" name="submit" class="submit action-button" value="Submit" />
</fieldset>
</form>
现在,当我点击提交按钮时,我不再被带到"其他页面.php"
我尝试将提交按钮包装在表单标签和发布周围,但这也不起作用。在这方面,我是一个新手,所以任何帮助将不胜感激。
谢谢!
编辑:-
这是javascript代码,如果它有帮助:
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches
$(".next").click(function(){
if(animating) return false;
animating = true;
current_fs = $(this).parent();
next_fs = $(this).parent().next();
//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50)+"%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'transform': 'scale('+scale+')'});
next_fs.css({'left': left, 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});
$(".previous").click(function(){
if(animating) return false;
animating = true;
current_fs = $(this).parent();
previous_fs = $(this).parent().prev();
//de-activate current step on progressbar
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
//show the previous fieldset
previous_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale previous_fs from 80% to 100%
scale = 0.8 + (1 - now) * 0.2;
//2. take current_fs to the right(50%) - from 0%
left = ((1-now) * 50)+"%";
//3. increase opacity of previous_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'left': left});
previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});
$(".submit").click(function(){
return true;
})
编辑 2:
也许,因为我现在正在使用javascript,而以前我没有,这意味着我不能像以前一样使用POST?我一直在搜索其他人的问题和互联网,但真的找不到解决这个问题的下一步。
好的,我实际上解决了它,我需要删除代码:
class="submit action-button"
从我的提交按钮,因为这阻止我使用"POST"命令,而是调用 jquery 文件,该文件内部只有一个 return:true。
我觉得我只是个白痴!
相关文章:
- 通过jQueryAjax一起发布Array和Form数据时出现问题
- 使用php解析xml并将其转换为json以与$.ajax一起使用时遇到问题
- 将clientWidth/clientHeight Javascript与webgl一起使用会返回问题
- 使用 :after 选择器与 slideToggle() 一起显示图标的问题
- 将 .show/.hide 与 .next 一起使用会导致问题
- 将“按$index跟踪”与过滤器一起使用时,出现错误.如何解决这个问题
- 将javascript与XML和XSLT一起使用时出现问题
- 关于“AngularJS与Plupload一起工作”的一些问题
- css的问题很重要,当与两个类一起使用时
- Highstock和Highmaps一起引发问题
- 尝试将IF语句与数组一起使用时遇到问题
- 将string.replace()Javascript与Unicode符号一起使用时出现问题
- 将javascript和jquery与XSL转换或函数参数混合在一起的问题
- 将.attr()与.get()一起使用问题
- PHP头文件不能与ajax一起工作.用js重新加载的问题
- 剑道图表第二个valueAxis问题,不能与axisCrossingValue一起工作
- 将elem.dataset与IE和JSFiddle一起使用时出现问题
- 将this.constructor与构造函数调用一起使用以访问静态属性时是否存在兼容性问题
- 奇怪的phpMyAdmin问题:内联编辑刚刚停止与下拉选择一起工作
- 让 CORS 与 JQuery 客户端、节点/快速服务器一起工作时出现问题