Solved

Need some help with checkbox jquery functionality.

Posted on 2014-03-08
4
314 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Summernote and form validation 10 95
Responsive CSS question 2 60
AWS CLI issues with Tags 3 63
Angular - disable input field on page load 4 12
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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 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…

911 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

18 Experts available now in Live!

Get 1:1 Help Now