我有一个奇怪的行为在我的形式,它发送数据从文本框,但它不发送按钮数据。
这是我的表格:
<form name="login_registro" method="POST" id="login_registro">
<input type="text" id="username" name="username" value="">
<input type="text" id="password" name="password">
<input type="submit" name="hacer_login" style="width:auto; height:auto; padding:5px;" class="button" onclick="submitForm('{{matches|last}}/entrar')" value="entrar">
<input type="submit" name="registro" style="width:auto; height:auto; padding:5px;" class="button" onclick="submitForm('{{matches|last}}/registro')" value="regístrate gratis!" >
</form>提交功能:
<script type="text/javascript">
function submitForm(action) {
document.getElementById('login_registro').action = action;
document.getElementById('login_registro').submit();
}
</script>在这两个页面(entrar和registro)中,我做了一个print_R($_POST);它只显示了两个输入,用户名和密码。它没有显示按下的按钮。
如果我删除onclick函数,并添加一个action="page.php“,它会发送两个输入加上按下的按钮。
我知道我能解决问题,但我想知道为什么会这样。谢谢。
PS:我评论了所有的jquery。
发布于 2014-10-19 13:34:09
function submitForm(action) {
document.getElementById('login_registro').action = action;
}我完全不明白你的回答:维琴提乌·巴乔尤,但你给了我一个提示。您说表单提交了两次,因此删除它在函数中提交表单的行对我有效。
https://stackoverflow.com/questions/26450230
复制相似问题