File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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: 980
    
    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: 60785
    
  65

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: 980
    
    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: 60785
    
  65

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: 980
    
    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: 60785
    
  65

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: 980
    
    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
 
Similar Threads
Iframes : script tag in JSP page
JSP and Javascript problem
Script using array
C:if misunderstanding
focus on input field