Refresh web page in bash script

hello,
I am trying to refresh my web page which is created in bash script.
I have a HTML page which when press a button calls a bash script. this bash script created the same page with dynamic data.
When pressing the button I am calling to a function that set time out of 7 seconds and and after 7 seconds it should call a function that simulate a button click and this should refresh the page. But this does not work. any advise?

HTML Code:

<!doctype html>
<html>
  <head>
<meta http-equiv="refresh" content="10"> 
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  </head>
  <script>
      function ClickRefresh()
        {    
           window.top.location.reload();
            document.getElementById("refreshbtn")[0].click();
        }
        function TimerRefresh()
        {
                window.setTimeout(ClickRefresh, 7000);
        }
   </script>
  <body>
    <form method="get" action="cgi-bin/createStatArea.sh" onsubmit="window.top.location.reload();" name="testStatusForm" >
    <div style="float:left; position:relative; width:250px; margin right:40px"> 
        <fieldset>
          <legend><h2>Test status</h2></legend>
        <textarea name="testStatus" id="testStatus" readonly>
            Please select the tests and set test parameters.
        </textarea><br><br>
        <button id="refreshbtn" onclick="TimerRefresh()">REFRESH</button><br><br>
        </fieldset>        
     </div>
    </form>
  </body>
</html>

BASH Code:

#!/bin/bash
printf "<!doctype html>"
printf "<html>"
printf     "<head>"
printf "<meta http-equiv="refresh" content="10">"
printf "<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">"
printf "</head>"
printf "<body>"
printf "<script>"
printf      "function ClickRefresh()"
printf         "{"
printf         "window.top.location.reload()";
printf        "document.getElementById("refreshbtn")[0].click();"
printf         "}"

printf      "function TimerRefresh()"
printf         "{"
printf        "window.setTimeout("ClickRefresh", "7000");"
printf         "}"
printf "</script>"
printf "<form method="get" action="cgi-bin/createStatArea.sh" onsubmit="window.top.location.reload"();"" name="testStatusForm">"
printf     "<div style=float:left; position:relative; margin-right:40px>"
printf         "<fieldset>"
printf            "<legend><h2>Test Status</h2></legend>"
printf "         <textarea name="testStatus" id="testStatus" rows="10" cols="30" readonly>"
printf "$(date +%d:%m:%Y) $(date +%X)\n"
printf "        </textarea><br><br>"
printf "<button id="refreshbtn" onclick="TimerRefresh"()"">REFRESH</button><br><br>"
printf "</div>"
printf "</form>"
printf "</body>"
printf "</html>"

Usually CGI need to return content type. And using HERE method it's easier to write web page with variable and command expand. Rest is html/javascript problem, not scripting.

#!/bin/bash
cat <<EOF
Content-type: text/html

<!doctype html>
<html>
  <head>
<meta http-equiv="refresh" content="10">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  </head>
  <script>
      function ClickRefresh()
        {
           window.top.location.reload();
            document.getElementById("refreshbtn")[0].click();
        }
        function TimerRefresh()
        {
                window.setTimeout(ClickRefresh, 7000);
        }
   </script>
  <body>
    <form method="get" action="cgi-bin/createStatArea.sh" name="testStatusForm" >
    <div style="float:left; position:relative; width:250px; margin right:40px">
        <fieldset>
          <legend><h2>Test 2 status</h2></legend>
        <textarea name="testStatus" id="testStatus" readonly>
            $(date) $(hostname)
        </textarea><br><br>
        <button id="refreshbtn" onclick="TimerRefresh()">REFRESH</button><br><br>
$(date)
        </fieldset>
     </div>
    </form>
  </body>
</html>

EOF