Jump to content

How do I add and remove information from form when "yes" and "no" boxes are checked?

Recommended Posts

Site URL: https://cone-raccoon-plbt.squarespace.com/config/settings/advanced/code-injection

I just want to have the register's be able to click "yes" in the checkbox and additional fields pop up to add more people with their information, and when "yes" is deselected, the information that was added disappears.  If they click "no" then nothing happens.  Currently, the "yes" adds the information, but when you deselect, nothing happens.  When "no" is checked, the entire form disappears.  I need help....

 

<style>
  #name-6a41b18c-53ef-4e09-a7e1-36a8a44d66ae,
  #email-ef3069e6-ed8d-485b-8122-415adba6e0b2,
  #phone-683a6bf2-d5c5-4f67-a80c-bf1514902460,
  #text-68e3fadc-13a1-4f5e-872d-cc617f41fdb3,
  #checkbox-9c352e37-6923-40d9-a177-d01ee9efdb96,
  #checkbox-0f847181-fa76-4ea2-9b47-31b148155a9d {
          display: none;
  }
</style>

 

src="https://code.jquery.com/jquery-3.6.0.min.js"
  integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
  crossorigin="anonymous"></script>

<script>
    $('#checkbox-731a364b-ad8f-4d92-b3a7-c3fe55fddcae input').click(function() {
        selection = $(this).val();
          
     if (selection == 'Yes') {
            $('.form-item').show();
      }
      else
            if (selection == 'No') {
               $('.form-item').hide();
            }
     
    });
</script>

Link to comment
  • Replies 1
  • Views 405
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

3 hours ago, JLatham said:

Site URL: https://cone-raccoon-plbt.squarespace.com/config/settings/advanced/code-injection

I just want to have the register's be able to click "yes" in the checkbox and additional fields pop up to add more people with their information, and when "yes" is deselected, the information that was added disappears.  If they click "no" then nothing happens.  Currently, the "yes" adds the information, but when you deselect, nothing happens.  When "no" is checked, the entire form disappears.  I need help....

 

<style>
  #name-6a41b18c-53ef-4e09-a7e1-36a8a44d66ae,
  #email-ef3069e6-ed8d-485b-8122-415adba6e0b2,
  #phone-683a6bf2-d5c5-4f67-a80c-bf1514902460,
  #text-68e3fadc-13a1-4f5e-872d-cc617f41fdb3,
  #checkbox-9c352e37-6923-40d9-a177-d01ee9efdb96,
  #checkbox-0f847181-fa76-4ea2-9b47-31b148155a9d {
          display: none;
  }
</style>

 

src="https://code.jquery.com/jquery-3.6.0.min.js"
  integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
  crossorigin="anonymous"></script>

<script>
    $('#checkbox-731a364b-ad8f-4d92-b3a7-c3fe55fddcae input').click(function() {
        selection = $(this).val();
          
     if (selection == 'Yes') {
            $('.form-item').show();
      }
      else
            if (selection == 'No') {
               $('.form-item').hide();
            }
     
    });
</script>

What is your site-wide password?

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.