www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] jquery checkbox.. .show div.. if unchecked hide div.

  1. #1
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    resolved [RESOLVED] jquery checkbox.. .show div.. if unchecked hide div.

    I'm looking for a bit of help creating this function.

    <div name="main">

    <checkbox></checkbox> If this is checked... display the div below.. if not checked.. don't display anything.

    </div>


    <div class='other' name='other' title='other' style='display:none;'>
    <input></input>
    <input></input>
    <input></input>
    </div>

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,126
    Here's a simple solution:
    http://jsfiddle.net/K8t8B/
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  3. #3
    Join Date
    Jun 2011
    Location
    California
    Posts
    383
    Hey cbVision,

    That worked out well, the only problem is that there is other checkboxes on the same page and it affects them all, how can i only associate it with the check box i want?

  4. #4
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Lightbulb

    acutally... still need help.. sorry.

  5. #5
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Question this allows me to select only my div and it populates correctly...

    FIXED!!!


    Code:
     <script type="text/javascript"> 	
     	$(document).ready(function(){
        $('#auth_required').change(function(){
            var checked = $(this).attr('checked');
            if (checked) { 
               $('.other').show();             
            } else {
                $('.other').hide();
            }
        });        
    });​
     </script>
    Last edited by Supplement; 11-13-2012 at 04:32 PM.

  6. #6
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,126
    Yep! You just target the ID of the checkbox you want. Strong work.
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles