aspose file tools*
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
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML Label field Watch "HTML Label field New topic
Author

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,
Mahendran
[ March 17, 2008: Message edited by: Mahendran Shanmugam ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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