将开机自检与多步骤表单一起使用时出现问题

Problems using POST with a Multi Step Form

本文关键字:问题 一起 表单 开机自检      更新时间:2023-09-26

>我有一个 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。

我觉得我只是个白痴!