aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes problem in getElementById Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "problem in getElementById" Watch "problem in getElementById" New topic
Author

problem in getElementById

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 998
    
    2
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

Joined: Jan 10, 2002
Posts: 61064
    
  66

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 998
    
    2

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
He means to replace



with



Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

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

Joined: Aug 20, 2011
Posts: 998
    
    2
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

Joined: Jan 10, 2002
Posts: 61064
    
  66

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

Joined: Aug 20, 2011
Posts: 998
    
    2
ya i got it....
Thank you Bear Bibeault..
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in getElementById