Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我想通过点击按钮获得$u POST[variablex],但不想发布_Php_Post - Fatal编程技术网

Php 我想通过点击按钮获得$u POST[variablex],但不想发布

Php 我想通过点击按钮获得$u POST[variablex],但不想发布,php,post,Php,Post,我的表单中有一个隐藏的元素,当我想要得到发布的值时 $variable=$_POST["variablex"] 我没有得到任何东西,在另一种情况下,当我在按钮(提交)上发布帖子时,它会使用默认值。。。帮助 <input type="hidden" name="variablex" id="variablex" value="555" /> <a onclick=" document.getElementById('variablex').value='123'; docu

我的表单中有一个隐藏的元素,当我想要得到发布的值时

$variable=$_POST["variablex"] 
我没有得到任何东西,在另一种情况下,当我在按钮(提交)上发布帖子时,它会使用默认值。。。帮助

<input type="hidden" name="variablex" id="variablex" value="555"  />
<a onclick=" document.getElementById('variablex').value='123';
document.getElementById('myform').submit();">123</a>

123
如果有人可以给我的例子链接或告诉我怎么做


谢谢:)

语法正常,尝试查看不同元素的id是否相同或表单的名称是否相同,或者如果您使用母版页,请检查是否有相同名称的表单或隐藏变量,我测试了您的代码,它工作正常…欢迎使用

<script>
function onclickFunction()
{
    document.getElementById('variablex').value='123'; 
    document.getElementById('myform').submit();
}
</script>
<html>
<body>
<input type="hidden" name="variablex" id="variablex" value="555"  />
<a onclick="onclickFunction();">123</a>
</body>
</html>
函数onclickFunction() { document.getElementById('variablex')。value='123'; document.getElementById('myform').submit(); } 123
用Jquery尝试回答这个问题

<script>
$(document).ready(function(){
    $("a#SOMEID").click(function(e){
        e.preventDefault();
        $("form#yourform").attr('action', $(this).attr('href')); /* If there are different links get its href and use it */
        $("#variablex").val($(this).text()); /* If you need to change the value of that input */
        $("form#yourform").submit();
    });
});
</script>
<form method="POST" id="yourform">
    <input type="hidden" name="variablex" id="variablex" value="555"  />
</form>
<a href="mypage.php" id="SOMEID">123</a>

$(文档).ready(函数(){
$(“a#SOMEID”)。单击(函数(e){
e、 预防默认值();
$(“form#yourform”).attr('action',$(this.attr('href'));/*如果有不同的链接,请获取其href并使用它*/
$(“#variablex”).val($(this).text());/*如果需要更改该输入的值*/
$(“表单#您的表单”).submit();
});
});

你的想法是当用户点击一个链接进入一个新的页面并发布秘密输入时?是的,谢谢,就是这样,在我的母版页中,我有相同的命名表单,没有mu隐藏变量…thx,对于愚蠢的noob错误,我深表歉意:)小心