-
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
-
try:
Code:
document.forms('FORM1').Address1.value
-
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 ;) :p