Object doesn't support this property or method

D

Darkstar 3D

Could I get some help on whats going on here. This thing worked in a
previous incarnation. The only change (as my feeble memory recalls) was
changes to the formating of the page.

Help!

http://www.thepurrfectnanny.com/map.php

Code block that errors is:

//Map Change function
function changeMap(){
//user_input = "kennesaw";
user_input = "";
for (i=0;i<document.forms[0].c1.length;i++) {
if (document.forms[0].c1.checked) {
user_input = document.forms[0].c1.value;
}
}
city = user_input;
onLoad(city);

}
 
D

Daz

Darkstar said:
Could I get some help on whats going on here. This thing worked in a
previous incarnation. The only change (as my feeble memory recalls) was
changes to the formating of the page.

Help!

http://www.thepurrfectnanny.com/map.php

Code block that errors is:

//Map Change function
function changeMap(){
//user_input = "kennesaw";
user_input = "";
for (i=0;i<document.forms[0].c1.length;i++) {
if (document.forms[0].c1.checked) {
user_input = document.forms[0].c1.value;
}
}
city = user_input;
onLoad(city);

}


Can you provide any hints as to the error you are seeing?
 
V

VK

Ref. Object doesn't support this property or method

Because you were a very bad boy :) so you did not pre-declare
user_input variable neither in global nor in local scope:
var user_input;
or
var user_input = "something';

Somewhere on your page you also have added an element with
id="user_input". On IE (always) and on Gecko (in BackCompat mode) it
leads to auto-created variable "user_input" referencing that element.
Because you did not use var the system assumes that you are trying to
assign empty string to that DOM element reference and this is indeed
not allowed.
 
D

Daz

VK said:
Ref. Object doesn't support this property or method

Because you were a very bad boy :) so you did not pre-declare
user_input variable neither in global nor in local scope:
var user_input;
or
var user_input = "something';

Somewhere on your page you also have added an element with
id="user_input". On IE (always) and on Gecko (in BackCompat mode) it
leads to auto-created variable "user_input" referencing that element.
Because you did not use var the system assumes that you are trying to
assign empty string to that DOM element reference and this is indeed
not allowed.

It's good practise to always use 'var' when declaring variables, unless
you have a specific reason not to. 'var' will make the variable private
to the scope it's in, and it should therefore save a lot of coding
problems, such as the one you experienced. I can't believe I didn't
spot it. Nice site by the way. :)

Daz.
 
D

Darkstar 3D

VK said:
Ref. Object doesn't support this property or method

Because you were a very bad boy :) so you did not pre-declare
user_input variable neither in global nor in local scope:
var user_input;
or
var user_input = "something';

Somewhere on your page you also have added an element with
id="user_input". On IE (always) and on Gecko (in BackCompat mode) it
leads to auto-created variable "user_input" referencing that element.
Because you did not use var the system assumes that you are trying to
assign empty string to that DOM element reference and this is indeed
not allowed.

Wow! I must have blinders on. :) Think I was too focused on the
conversion or something.

Mucho thanks! Great explanation too as I learned a bit as well.
 
D

Darkstar 3D

Daz said:
It's good practise to always use 'var' when declaring variables, unless
you have a specific reason not to. 'var' will make the variable private
to the scope it's in, and it should therefore save a lot of coding

I do try, still fuming that I missed some. Although, I must admit that
I don't do webpages for a living, but this client was the wife! :)
Nice site by the way. :)

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top