File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes getElementById( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "getElementById("flight_no") returns undefined" Watch "getElementById("flight_no") returns undefined" New topic

getElementById("flight_no") returns undefined

nilesh beit

Joined: Feb 04, 2009
Posts: 13
Respected members
I have a Div tag named 'composeplan' which on clicking on a button displays a few textboxes. i used innerHTML to replace contents in div tag with html text for creating Textboxes using <input type="text" > etc to display those textboxes
Now when i try to read value in textbox using its id like document.getElementById("flight_no") i get 'undefined' as value
I tried document.getElementById("flight_no").value still output 'undefined'
document.getElementById("flight_no").id returns 'flight_no' i.e id of text box

Can please suggest some solution to read value from textbox.

Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

How do you define the textbox ? do you have "id" attribute for it ?

like <input .. id=" " .. name=" " >

Post your code otherwise.
nilesh beit

Joined: Feb 04, 2009
Posts: 13
This is code similar to what m trying to do
The problem is readContents shows 'undefined'
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.

[Asking smart questions] [About Bear] [Books by Bear]
Aditya Keyal
Ranch Hand

Joined: Dec 01, 2008
Posts: 71
Which browser are you using. When i try the above code in IE7 it works perfectly fine.

- Aditya Webservices Blog
nilesh beit

Joined: Feb 04, 2009
Posts: 13

Solved it

Damn it was Eclipse bug . It typed .value as .Value in document.getElementById("name").value
The V instead of v which made all mess.
Thanks for the responses.
I agree. Here's the link:
subject: getElementById("flight_no") returns undefined
It's not a secret anymore!