It is not possible with your current layout.
You have, in effect, 2 programs in one file.
<title> Untitled </title>
Put your code in the appropriate positions with only one set of <HTML> and <body> tags.
You can have multiple <script> and <div> and <input>, but not multiple <HTML> tags.