Solved

Need some help with checkbox jquery functionality.

Posted on 2014-03-08
4
311 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
  • 2
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
There is no
$('.delete a').click(function() {

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

Author Comment

by:brihol44
Comment Utility
Yes, I created it on my own.

http://jsfiddle.net/DXK3Q/

thx again!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
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)

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now