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
1) if php condition is true, I added javascript.
2) I added php in my form submit button code.
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.
You are executing the script before the element is created. Move the code below the element to work
没有display
这样的属性,您需要改用style="display: none"
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.