[英]HTML display=none doesn't work
My code: 我的代码:
<?php
if($counter==0) {
echo "value of counter = $counter"
?>
<script type='text/javascript'>
document.getElementById("tt").style.display = "none";
</script>
<?php
}
?>
<html>
<body>
<form action="new_upload.php" method="post" name="myform" enctype="multipart/form-data" id="formform">
<input type='submit' value='Go Back!' name="sbmt" id="tt"
<?php if($counter==0) { ?> display="none" <?php } ?> />
</form>
<p> Submit a different file by clicking the back button in case your file was unable to upload.</p>
</body>
</html>
You can see I have tried to set the property display=none of the submit button through 您可以看到我尝试通过以下方式将属性display = none设置为Submit按钮
1) if php condition is true, I added javascript. 1)如果php条件为true,则添加了javascript。
2) I added php in my form submit button code. 2)我在表单提交按钮代码中添加了php。
but it is not working both ways. 但它不能双向工作。 I can see through the print statement that the value of counter is 0 but then also it is visible. 我可以通过print语句看到counter的值为0,但是它也是可见的。
You are executing the script before the element is created. 您正在创建元素之前执行脚本。 Move the code below the element to work 将代码移到元素下方即可工作
没有display
这样的属性,您需要改用style="display: none"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.