在PHP中,有一个表单将变量发送到同一页面。我想做一个jQuery显示/隐藏一个特定的div(使用ID);如果值被发送(表单被发送到同一页面),我想显示div
在PHP文件中,我有这样的形式:<form action="<?=$_SERVER['PHP_SELF'];?>" method="get">
<input type="hidden" name="status" value="12345">
<input type="submit">
</form>
链接的js文件中的,如何检测发送的隐藏值"status"?如果$_GET["status"]不为NULL,我想显示$('specificID').show();,它最初是:
$(document).ready(function (){
$('#specificID').hide();
}
谢谢。
你必须像这样在PHP中嵌入你的JS:
<?php
some php...
?>
some markup...
$(document).ready(function (){
<?php
if($_GET["status"]):
?>
$('#specificID').show();
<?php
else:
?>
$('#specificID').hide();
<?php
endif;
?>
});
...
$_GET["varname"]
http://www.w3schools.com/php/php_get.asp http://www.skytopia.com/project/articles/compsci/form.html