I'm a beginner working on a time conversion app. Currently, the application takes the value entered into the form and then changes the h2 element with the ID "convDate" to the entered value * 2 and then displays the result in the h2 element.
The application does run successfully, but the value immediately disappears from the screen. The changes do stick if I hold CTRL while clicking the button, while also opening the same page in a new tab. I've tried with both Brave and Firefox.
Can somebody explain the logic as to why this is happening? Any information is appreciated. Though, please note that I'm not looking for somebody to finish the app. I'm trying to understand concepts.
Thanks!
<h1>64 Bit Unix Time Converter</h1>
<form>
<input id='unixTime' type='text'>
<button class='button' onclick='convert()'>Convert</button>
<h3>Value: </h3>
<h2 id='convDate'></h2>
</form>
<script>
function convert() {
var entValue = document.getElementById('unixTime').value;
var conValue = document.getElementById('convDate').value;
document.getElementById("convDate").innerHTML = (entValue * 2);
};
</script>