0

I have a simple HTML form in Mockup.html asking for your name. Clicking the "say my name" button should have the same html file output the name provided... but it doesn't.

Am I missing something?

<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <title>Untitled Document</title>
</head>

<body>
  <script language="javascript">
    function $_GET(q, s) {
      s = s ? s : window.location.search;
      var re = new RegExp('&' + q + '(?:=([^&]*))?(?=&|$)', 'i');
      return (s = s.replace(/^?/, '&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined;
    }

    var usersName = $_GET('username');
    if (typeof(usersName) != 'undefined') {
      document.write('<h1>Hi there, ' + usersName + '</h1>');
    }
  </script>

  <form>
    <input type="text" name="username" />
    <input type="submit" value="Say my name" />
  </form>

</body>

</html>

I can see the form, the url bar updates to reflect the variable input, but the page won't display it.

Note that I DO NOT want to upload this to a web server. The html file should run from a local harddrive without internet access.

Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81
Sweepster
  • 1,829
  • 4
  • 27
  • 66

0 Answers0