Solved

ExtJS Question: Retrieving id of label?

Posted on 2008-10-31
5
417 Views
Last Modified: 2013-11-11
I'm trying to return the name of a label once a checkbox has been selected.

The html looks like this:
<label name="myName"><input type="checkbox" id="n1" name="n1" value="2" /></label>

I've tried:

var checkboxid = $('n1');

var label = parent.checkboxid;

var labelname = label.name;
 

alert(labelname);

Open in new window

0
Comment
Question by:n00b0101
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
Comment Utility
try:
var checkboxid = $('n1');
var label = checkboxid.parentNode;
var labelname = label.name;
0
 

Author Comment

by:n00b0101
Comment Utility
I tried the above, and I also tried:

var checkboxid = $(this);
var label = checkboxid.parentNode;
alert(label.name);

And just get: label is undefined
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
Comment Utility
make sure no other element has:
id="n1"

then try:
var labelname =$("#n1").parent().name;
0
 

Author Closing Comment

by:n00b0101
Comment Utility
sorry so late!
0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
glad to help
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now