Javascript 从上一页的输入值显示/隐藏div id
我发现解决这个问题很困难。我想使用上一页的表单输入数据来显示或隐藏特定的div idJavascript 从上一页的输入值显示/隐藏div id,javascript,php,html,show,hidden,Javascript,Php,Html,Show,Hidden,我发现解决这个问题很困难。我想使用上一页的表单输入数据来显示或隐藏特定的div id <form action="http://example.com/example/" method="post"> <input type="hidden" id="example" name="example" value="<?php echo $site; ?>"> <input class="examplesu
<form action="http://example.com/example/" method="post">
<input type="hidden" id="example" name="example" value="<?php echo $site; ?>">
<input class="examplesubmit" type="submit" value="Submit">
</form>
您可以通过以下方式实现:
第1页
<form action="index2.php" method="post">
<input type="hidden" id="example" name="example" value="foo">
<input class="examplesubmit" type="submit" value="Submit">
</form>
第2页(index2.php)
您可以仅在同一页面中包含这两个内容,默认情况下隐藏内容,仅显示并单击提交按钮
<form action="http://example.com/example/" method="post">
<input type="hidden" id="example" name="example" value="<?php echo $site; ?>">
<input class="examplesubmit" type="submit" value="Submit">
</form>
这是jquery或javascript,对不起,我更喜欢jquery
<script>
$(function(){
$("#testing").hide();
$('.examplesubmit').click(function(e){
e.preventDefault();
$("#testing").show();
});
});
</script>
$(函数(){
$(“#测试”).hide();
$('.examplesubmit')。单击(函数(e){
e、 预防默认值();
$(“#测试”).show();
});
});
到目前为止,您是否编写了任何服务器端代码来尝试解决此问题?我会将其放在url的参数中,比如site.xz/form/page2/?whatever=yes
值是动态的,我想使用动态值。怎么做?我试过了,但没用。我使用wordpress平台。。在本例中,将page.php转换为单个php。我希望在用户单击submit按钮时显示div,否则不显示内容。我尝试使用WebCode.ie用户建议的foo方法。是的,如果该值是固定的,它会工作,但我在应用于“不工作”时使用“动力学”值。3天多的时间来解决这个问题让我很沮丧:(
<form action="http://example.com/example/" method="post">
<input type="hidden" id="example" name="example" value="<?php echo $site; ?>">
<input class="examplesubmit" type="submit" value="Submit">
</form>
<?php require_once 'page2.php'; ?>
<script>
$(function(){
$("#testing").hide();
$('.examplesubmit').click(function(e){
e.preventDefault();
$("#testing").show();
});
});
</script>