Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object does not support property error!

 
Natalie Ap
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to run the following piece of code, but I am getting a javascript error "Object does not support property error!" and I am unable to understand what the problem might be.

There is a form called "updateForm" which I am trying to submit when i get the error. When I comment lines (1), (2), (3), the error does not get thrown. Please help me!!

Please let me know if you need any other information besides this.

Thanks,



 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well first problem is document.all is IE only.

You should be using document.formName.elementName or
You should be using document.forms["elementName"] or
You should be using document.forms[0].elementName or
document.getElementById("elementID")

Eric

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello wrote:document.forms[0].elementName
This is not specific enough, I wouldn't use it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree. The [0] notation is rather old-fashioned and is fragile. Avoid it.

id values allows you to specifically target an item without ambiguity.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic