Solved

ExtJS Question: Retrieving id of label?

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

717 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