Error when trying to refer to a field by name

Posted by raja on Stack Overflow See other posts from Stack Overflow or by raja
Published on 2010-06-09T15:49:04Z Indexed on 2010/06/09 16:12 UTC
Read the original article Hit count: 278

Filed under:

I am getting an error (document.my_formm.fieldName.value is null or not an object) from the below code:

<html>
  <head>
    <title>(Type a title for your page here)</title>

    <script language=JavaScript>
    function check_length(my_formm,fieldName)
    {
      alert(fieldName);
      alert(document.my_formm.fieldName.value);
    }
    </script>
  </head>
  <body>
    <form name=my_form method=post>
      <input type="text" onChange=check_length("my_form","my_text"); name=my_text rows=4 cols=30 value="">
      <br>
      <input size=1 value=50 name=text_num> Characters Left
    </form>
  </body>
</html> 

© Stack Overflow or respective owner

Related posts about JavaScript