SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast thenovice's Avatar
    Join Date
    Mar 2001
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Despo Javascript Newbie

    Hi

    I'm trying to learn javascript. I've a problem with NN4.76 and NN6.2.1. Both complain about "myform is not defined.". IE6.0 and Opera6.01 seem to be ok, atleast they give the expected result.

    I shan't waste your time...here's the <form> tag and the JS code I have--

    <script language="Javascript" type="text/javascript">
    <!--
    //in the HEAD tag
    function display()
    {
    var fame = myform.firstname.value;
    var same = myform.secondname.value;
    alert(fame + ' ' + same);
    }
    //-->
    </script>

    and the <FORM> tag

    <form name="myform">
    Enter first name:
    <input name="firstname" type="text" value="" length="6" tabindex="1">
    <br>
    Enter second name:
    <input name="secondname" type="text" value="" length="6" tabindex="2">
    <br>
    <input type="button" name="bmyform" value="Enter" onClick="display()" tabindex="3">
    </form>

    Any help/suggestion/guidance would be greatly appreciated. Thanks in advance and sorry if the formatting is sloppy.
    :: There are some who live in a dream world, and there are some who face reality; and then there are those who turn one into the other ::

  2. #2
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With netscape you need to preface it with the word document like this:
    var fame = document.myform.firstname.value;
    var same = document.myform.secondname.value;

    Forgot to say that this is also supported by IE and Opera.

  3. #3
    SitePoint Enthusiast thenovice's Avatar
    Join Date
    Mar 2001
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Much obliged for the reply. Will try to work on it and let u know how it turns out. Thanks again !! :-)
    :: There are some who live in a dream world, and there are some who face reality; and then there are those who turn one into the other ::


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •