Closed Thread Icon

Topic awaiting preservation: Input Object Issue (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=26788" title="Pages that link to Topic awaiting preservation: Input Object Issue (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Input Object Issue <span class="small">(Page 1 of 1)</span>\

 
NeoNeo
Obsessive-Compulsive (I) Inmate

From:
Insane since: Aug 2005

posted posted 10-04-2005 22:16

Has anyone ran into this problem?

I am rendering a button.
The id and name had a capital letter. ?submitButton? ?submitButton?

code:
<input id="submitButton" name=" submitButton " 
value="ok" type="button" title="submit" onclick="submitButton();" />


For some reason I would see the following js error: object doesn't support this property or method. When I clicked the button.

When I changed to the id and name for the button to all lower case "submitbutton", everything works fine.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-04-2005 23:42

Internet Explorer incorrectly adds all name's (and maybe id's) of objects as global variables. So when you say submitButton(), it thinks you're trying to call the <input> tag itself as a function. Renaming the tag (javascript is case sensitive) prevented this.

This is Internet Explorer's fault, because submitButton shouldn't be a global variable.


 

NeoNeo
Obsessive-Compulsive (I) Inmate

From:
Insane since: Aug 2005

posted posted 10-05-2005 17:44

ahhhh i see... this is a good thing to know.

Thanks

TwoD
Bipolar (III) Inmate

From: Sweden
Insane since: Aug 2004

posted posted 10-06-2005 16:29
quote:
This is Internet Explorer's fault, because submitButton shouldn't be a global variable.


"Newbie" scripters often find this feature useful since they don't like to use long document.... references.
However, when they get more experienced they tend to hate it hehe.

/TwoD

Scott
Paranoid (IV) Inmate

From: schillmania.com
Insane since: Jul 2002

posted posted 10-09-2005 19:16

Use document.getElementById() wherever possible, and avoid using name attribute values like "map" and other values that may be reserved keywords by script or the browser.

TwoD
Bipolar (III) Inmate

From: Sweden
Insane since: Aug 2004

posted posted 10-09-2005 19:41

I love the document.getElementById() method but I tend to mistype it or forget document.
So here's a small tip:

code:
function getId(id){
 return document.getElementById(id)
}


In there, you could also easily specify an alternative way to reference objects if the browser doesn't support getElementById().

/TwoD

« BackwardsOnwards »

Show Forum Drop Down Menu