Solved

Need some help with checkbox jquery functionality.

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)

756 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