<form action="index.php?page=checkin" method="post" name="regForm">
    <div id="First_1">
        <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="5">
                        <tr>
                            <td style="padding: 5px;">
                                Fullständiga namn:
                            </td>
                            <td>
                                <input name="full_name" type="text" id="full_name" class="required">
                            </td>
                        </tr>
                        <tr>
                            <td style="padding: 5px;">
                                Email:
                            </td>
                            <td>
                                <input name="usr_email" type="text" id="usr_email3" class="required">
                            </td>
                        </tr>
                        <tr>
                            <td style="padding: 5px;">
                                Sex:
                            </td>
                            <td>
                                <select name="sex">
                                    <option value="male">
                                        Kille
                                    </option>
                                    <option value="female">
                                        Tjej
                                    </option>
                                </select>
                            </td>
                        </tr>
                        <td>
                            <input type="submit" id="continue" value="Fortsätt">
                        </td>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <div id="Next_2" style="display: none">
        <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="5">
                        <tr>
                            <td style="padding: 5px;">
                                Lösenord:
                            </td>
                            <td>
                                <input name="pwd" type="password" class="required password" id="pwd">
                            </td>
                            <td>
                                En gång till..
                            </td>
                            <td>
                                <input name="pwd2" id="pwd2" class="required password" type="password">
                            </td>
                            <td>
                                <input name="doRegister" type="submit" id="doRegister" value="Register">
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</form>
<script type="text/javascript">
    $(function() {
        $("#continue").click(function() {
            $.ajax({
                type: "POST",
                url: "dbc.php",
                data: {
                    check: 'First',
                    full_name: $('#full_name').val(),
                    usr_email: $('#usr_email3').val()
                },
                success: function(msg) {
                    if (msg == '1') {
                        $("#First_1").hide();
                        $("#Next_2").toggle();
                    } else {
                        alert(msg);
                    }
                }
            });
            return false;
        });
    });
</script>


那是我的表格。首先填写3个表单元素,然后按“继续”按钮,然后它发送ajax调用以检查字段。如果一切正常(如果ajax调用的输出= 1),则Next_2处于打开状态,在此输入两次密码。之后,您按最后一个按钮Register,该按钮应该执行“ action = index.php?page = checkin”,但没有,当我按register时,它只是空白,我在Firebug中看到它发送了另一个Ajax调用我不明白,因为按钮没有id =“ continue”但id =“ doRegister”

最佳答案

由于“继续”按钮实际上并未提交表单,因此请尝试将其声明为普通按钮而不是提交按钮,如下所示:

<input type="button" id="continue" value="Fortsätt">


我猜想在同一表单上有两个提交按钮会以某种方式引起与处理程序的交互。

关于php - 表格2按钮+ JavaScript问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3382610/

10-12 12:44
查看更多