I'm very new to PHP, JS, and HTML so I hope you don't mind if the question is very trivial. So I basically have the following code, the onlick
would work in a separate HTML file but it will not work if I put this in an echo of a PHP file or put it in a separate html block inside a PHP file.
button.html (this works)
<body>
<p>Click the button to display the time.</p>
<button onclick="getElementById('demo').innerHTML=Date()">What is the time?</button>
<p id="demo"> </p>
</body>
</html>
Here is the echo code:
button.php (doesn't work)
<?php
....
....
echo "
<input type ='button' value = 'Date' onclick = 'getElementById('demo')=Date();' />
<p id='demo'> </p>
"
?>
This is the HTML code inside PHP file that doesn't work.
button.php (doesn't work)
<?php>
?>
<html>
<body>
<p>Click the button to display the time.</p>
<button onclick="getElementById('demo').innerHTML=Date()">What is the time?</button>
<p id="demo"></p>
</body>
</html>
Any help would be appreciated!