?
Solved

ExtJS Question: Retrieving id of label?

Posted on 2008-10-31
5
Medium Priority
?
423 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

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

Author Comment

by:n00b0101
ID: 22853186
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 2000 total points
ID: 22853214
make sure no other element has:
id="n1"

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

Author Closing Comment

by:n00b0101
ID: 31514683
sorry so late!
0
 
LVL 82

Expert Comment

by:hielo
ID: 22913749
glad to help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

741 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