Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in getElementById

 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell me why my this code is not working, or what i am doing wrong?


when i m trying to alert name, it's showing me [object] instead of the text field value.
therefore checking of null is also not happening here..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's doing exactly what you are telling it to do. You are assigning the element object to name, so that's what it's showing.

P.S. Debugging with alerts? Why aren't you using the JavaScript console?
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

JavaScript console


did you mean by js console on browser (ie firebug in mozilla)
if you mean, i m using that but that console nothing showing me..
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He means to replace



with



Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed, the JavaScript console isn't just for displaying errors -- it's a full debugging environment. Learn to use it. It would have shown you that the variable name is a reference to the element, not just its value.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i added this:



but nothing is visible to me on the console, i m using eclipse.

also how do i solve this problem?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, once you have a reference to the input element, you can get the value via the value property.

I suggest getting a good JavaScript reference.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i got it....
Thank you Bear Bibeault..
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit Jain wrote:
but nothing is visible to me on the console, i m using eclipse.

also how do i solve this problem?


The console in the browser, not your IDE.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic