1 Reply Latest reply on Feb 14, 2010 3:55 PM by Ned Murphy

    Javascript passing variables?

    JonnyDL-HV74P1 Level 1

      I'm in the process of taking a Javascript course and I seem to be hitting a wall early. Id like to pass a variable from a text field into another page

      (right now Im trying ti pass it just to an alert window). I looked on the web and tried different variations of what I saw, and I eithier got an undefined error, or nothing at all.

       

      Here is the html I have using a text field

            <form subject="myname" enctype="text/plain">

              <p class="guesttext">Please enter your name to our guest book:  <INPUT TYPE="text" NAME="firstname" SIZE=20/> <input type="button" onClick="show_alert()" value="Guest Book"/> </p>

            </form>

       

      here is the javascript I have (in one of its many versions

      <script type="text/javascript">

      function show_alert()

      {

      var text = document.myname.firstname

      alert(text)

      }

      </script>

       

      Can anyone see what I'm missing in my code?