?
Solved

Need some help with checkbox jquery functionality.

Posted on 2014-03-08
4
Medium Priority
?
332 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

807 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