SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Vancouver, BC
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select all checkboxes with jQuery issue

    Hey guys,

    I have this jQuery script 'script.js' that is supposed to select all checkboxes in a form. You can see the page here:

    http://datawatch.ze.com/advanced-search/

    However it doesn't work. There's no errors in the code. It was working locally but when I uploaded the entire site to a new server it broke. I'm assuming it's an issue with the path to script.js because other jQuery elements are broken that use the same script, for example the jQuery slider at the bottom of the page.

    Any help would be much appreciated. Thanks.

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The problem is your currently two different releases of jQuery into the page one of which doesn't support the .on() method because of how old it is, see the below for the line to remove

    Code:
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script> <!-- REMOVE THIS LINE -->

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Vancouver, BC
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot Chris. I removed that line and now the slider at the bottom of page works! Thanks!!! However, the select all on this page, http://datawatch.ze.com/advanced-search/ still does not work? Any ideas?

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Currently the way the code is written it will never fire because the anchor never has a class of active, the following should fix the issue.

    Code JavaScript:
    $($(this).attr('href') + ' input:checkbox').prop('checked', function() {
        return !$(this).prop('checked');
    });

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Vancouver, BC
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again Chris! You're awesome!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •