Solved

Need to target a checkbox

Posted on 2012-04-03
2
177 Views
Last Modified: 2012-04-09
I have a click event that sets a checkbox to be checked, however it is targeting all the checkbox on the page with the same class.

I only want to target the checkbox that was clicked. Using Mootools.

var checkEmail = $$('input.user-address');
          $$(".content .addcheck").addEvent('click', function () {
              alert('test');
              checkEmail.set('checked',true);            
          });
0
Comment
Question by:yando18
[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
2 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 37803349
You need to use a unique id for any checkbox that you want to target individually.  Any reference using a class name always targets every member of the class.

Cd&
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 37804240
What about : http://jsfiddle.net/hJbuD/
    $$(".content .addcheck").addEvent('click', function () {
        this.getPrevious('input.user-address').set('checked',true);             
    })¿

Open in new window

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
center navbar (navigation menu) on web page 3 60
Boolean 13 46
Geolocation works...sometimes 2 34
iframe stay to the left of page 5 27
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

738 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