Using "document.getElementById" to insert form value - is it possible?

Is it possible to do something like this - would like to sub in a form field value with this javascript code. Can it be done, not sure if it is a syntax thing or just not possible.

<p>Display "Test" </p>

<p id="demo">Fail</p>

<script>
if (5 < 18) {
  document.getElementById("demo").innerHTML = form1.calcweight.value;
}
</script> 
Community Page
Last updated: