I have a popup from index.ejs, called math.ejs. After pressing the submit Ok button, I want the math.ejs popup to close and to show the calculated value on index.ejs. But right now, when I press the submit button, the popup goes to index.ejs and updates it there; it does not close. It does not update it on the normal index.ejs browser page. I have to refresh that page for it to update.

<form class="" action="/index" method="post" name="mathform">
      <p>Value: <%= myValue %></p>
      <button class="btn btn-md" name="button" value="confirm" onclick="CloseAndRefresh();">Ok</button>
  </form>

<script language="javascript">
  function CloseAndRefresh() {
    opener.location.reload(true);
    setTimeout(function() {
    window.close();
  }, 3000);
  }
</script>

Any help would be appreciated. Thank you.