It's not a secret anymore!*
The moose likes HTML, CSS and JavaScript and the fly likes how to get element's Id or name for dynamically created element(textbox) 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 "how to get element Watch "how to get element New topic
Author

how to get element's Id or name for dynamically created element(textbox)

zimbu bolleddu
Ranch Hand

Joined: Jan 14, 2008
Posts: 35
Hi all,

I have created some textboxes dynamically by using

var sun = document.createElement('input');

with button click.

after some time I will re visit the fields, how do I retrive that element's Id or name onblur event.

Bythe following code I used to get the value of the specified element, but I want id or name of that element .

code examples are highly appreciated.

Thanks & regards,
zimbu
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 614
you cannot retrieve id and name if its not assigned. try following code



[ August 29, 2008: Message edited by: Praful Thakare ]

All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

I really don't know what you are asking. Did you give the element an id when you created it? If not, it doesn't have one. If you did, then what's your question? If you have a reference to the element, you can retrieve its id (if it has one). If you have the id, you can get a reference to the element. If you don't have either of these, you need some other way to uniquely identify the element in order to find it.
[ August 29, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get element's Id or name for dynamically created element(textbox)
 
Similar Threads
How can I create fully qualified names using a sax DefaultHandler
Faulty JavaScript works in WebSEAL environment?
SAX praser passing element's attribute value dynamically
problem javascript
dynamic color