0

I'm not able to find the mistake. I'm getting "Cannot read property 'fn' of undefined" Following is my code:

<body>
  <form name = "NumberForm">
    <h1>Please enter two numbers</h1>

    <font face="Courier New">
      First Number: <input name = "fn" size="50" type="text"><br>
      Last Number:&nbsp; <input name="ln" size="50" type="text"><br>
    </font>

    <input type="button" value="Submit" onclick="doSubmit()">

  </form>

  <script>
    function doSubmit()
    {
      var firstNumber = document.NumberForm.fn.value;//error is marked here
      document.write(firstNumber);
    }
  </script>

Megha608
  • 1
  • 1
  • I'd also look at http://stackoverflow.com/questions/3547035/javascript-getting-html-form-values you may want to get form elements by Id instead.. – Woodrow May 13 '17 at 00:47

1 Answers1

0

Try document.forms['NumberForm'].fn.value

Woodrow
  • 2,740
  • 1
  • 14
  • 18
  • This is also giving the same error. I figure it out. My javascript that i'm actually running is having document.write(); before coming to this error marked line. If i remove that line it works properly. Can you tell me why is that happening if u know.. – Megha608 May 24 '17 at 00:33