?
Solved

Need some help with checkbox jquery functionality.

Posted on 2014-03-08
4
Medium Priority
?
327 Views
Last Modified: 2014-03-10
I had posted a similar request a couple of days ago and got it working but I've re-worked my functionality to use checkboxes instead.

1. My checkboxes are visible in the jsfiddle link below for testing only but they will be hidden so they don't really have any functionality than values I will update a form with.

2. Basically if you select heading 1 "Delete" link all sub-set checkboxes should have toggle functionality  including the heading checkbox. I have it working so all sub-set checkboxes are checking but there's some thing I'm not getting with getting them to uncheck when clicking the "Delete" link again. And you can see the main heading checkbox never gets checked or unchecked when clicking the main "Delete" link.

3. I would also like to click the "X" link to individually (toggle) set the related checkbox checked or not checked as well.

Thanks for the help,


http://jsfiddle.net/vcWVS/
0
Comment
Question by:brihol44
[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
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 1000 total points
ID: 39915884
This should be all you need
http://jsfiddle.net/GaryC123/vcWVS/3/

$('.pull-right a').click(function() {
     var $checkbox = $(this).next("input")
    $checkbox.prop("checked",!$checkbox.prop('checked'))
   $(this).closest(".heading").next('div').find("input").prop("checked",$checkbox.prop('checked'));
})
$('.pull-right input').click(function() {
   $(this).closest(".heading").next('div').find("input").prop("checked",$(this).prop('checked'));
})

Open in new window

0
 

Author Comment

by:brihol44
ID: 39915906
ok, thx! And from that I was able to add in the other part I needed.

$('.delete a').click(function() {
  var $checkboxt = $(this).next("input");
  $checkboxt.prop("checked",!$checkboxt.prop('checked'))
});

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 39915912
There is no
$('.delete a').click(function() {

So that function is defunct - it will never be called.
0
 

Author Comment

by:brihol44
ID: 39915936
Yes, I created it on my own.

http://jsfiddle.net/DXK3Q/

thx again!
0

Featured Post

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

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

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
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
Course of the Month10 days, 18 hours left to enroll

770 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