Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:03:10+00:00 2026-06-15T17:03:10+00:00

Simple form which will show additional fields (div class=fold) if a checkbox (div id=foldstate)

  • 0

Simple form which will show additional fields (div class=”fold”) if a checkbox (div id=”foldstate”) is marked.

Clicking checkbox hides/shows additional fields as expected.

Checking the checkbox, filling out the additional fields and submitting (preview) the forms input with php for some server side validation shows up checkbox checked but the fold got still <div class="fold" style="display: none;">

Where is my mistake?

My jQuery code:

$(document).ready(function() {
    if ($("#foldstate").not(":checked")) {
        $(".fold").css("display","none");
    }
    $("#foldstate").click(function(){
        if ($("#foldstate").is(":checked")) {
            $(".fold").show("fast");
        }
        else {
            $(".fold").hide("fast");
        }
    });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:03:11+00:00Added an answer on June 15, 2026 at 5:03 pm

    The .not() function will return a collection of JQuery object or either a empty collection, when your checkbox isn’t checked. In both cases your code will evaluate to true, so that you always get display:none.

    As you are sellecting by ID, I would suggest you to replace this block:

    if ($("#foldstate").not(":checked")) {
        $(".fold").css("display","none");
    }
    

    By this:

    if (!$("#foldstate").attr("checked")) {
        $(".fold").css("display","none");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to develop a simple program which will show a form with a
I want to make a simple validation form, which will show warning message, when
I have a simple button which will open up the AddStation form (this button
I have this simple form which shows a pop up calendar when clicked on
I have a simple modal form which I'd like to close when Esc is
I have written a simple CRUD form which has one select list. However the
I am trying to create a simple GUI form which has only 2 elements
I have simple form like this which accepts only two values string action and
I have a simple html login form which is validated with javascript before its
I have a simple form at my site which sends it data via Ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.