Solved

ExtJS Question: Retrieving id of label?

Posted on 2008-10-31
5
419 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
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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
where is team.js? 3 27
Javascript Form Change 5 23
If condition on Html with Asp 11 18
Multiflying 2 Input Text On a Table 7 22
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

825 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