wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes HTML Label field's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML Label field Watch "HTML Label field New topic

HTML Label field's "for" attribute problem

Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Hi guys,

I have the following HTML content

I wanted the change the label text from javascript method. The labels for attribute is pointing towards the TextBox.
The Problem is I cannot add id attribute for label.(This code is auto generated from some custom tags). How do I can change the label for the corresponding TextBox?

Please give me your comments,
[ March 17, 2008: Message edited by: Mahendran Shanmugam ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60774

Custom tags that don't let you specify basic and essential HTML attributes like id are not something I'd consider using. Do you have control over these tags?

If not, then you'll need to use DOM traversal to locate a reference to the element.

Some libraries like Prototype and jQuery can help you do this easily. In Prototype, the $$() function can help you find element by via CSS attributes. in jQuery you'd do something as simple as:

[ March 17, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Thanks Bibeault,

I got it.
I agree. Here's the link: http://aspose.com/file-tools
subject: HTML Label field's "for" attribute problem
Similar Threads
How to get Div values in the html
jQuery select option
JSON response into HTML
Problem in creating a search result page
How to get nodes from Selection/Range ?