Results 1 to 3 of 3

Thread: Is Null or not an object

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2002
    Location
    Hampton Beach
    Posts
    513

    Question Is Null or not an object

    I am trying to place the value of the variables into this url but I keep getting this error on my variables:

    <script language = javascript>
    var Address1 = FORM1.Address1.value
    var Address2 = FORM1.Address2.value
    var Province1 = FORM1.Province1.value
    var Province2 = FORM1.Province2.value

    window.open('http://www.mapquest.com/directions/main.adp?go=1&do=nw&ct=NA&1y=US&1a=" & Address1 & "&1p=&1c=" & City1 & " &1s=" & Province1 & "&1z=&1ah=&2y=US&2a=" & Address2 & "&2p=&2c=" & City2 & "&2s=" & Province2.value & "&2z=&2ah=&lr=2&x=66&y=11','NewWindow')
    </script>

    I keep getting the error:
    Line 17: Error: 'FORM1.Address1.value' is null or not an object

    My form is named FORM1...

    What other ways can I try for example:

    window.document.FORM1.Address1.value

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    try:

    Code:
    document.forms('FORM1').Address1.value
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Not sure how things have changed over the years, but you've gotta follow the hierarchy of objects. The highest is window, then document, then there comes in your form.

    So document.<formname>.<fieldname>.value should work. So try putting 'document.' infront of your FORM1

    Code:
    var Address1 = document.FORM1.Address1.value
    var Address2 = document.FORM1.Address2.value
    var Province1 = document.FORM1.Province1.value
    var Province2 = document.FORM1.Province2.value
    Or see if Hobo's code works

Posting Permissions

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



Click Here to Expand Forum to Full Width