Jump to content

Hiding form fields

Recommended Posts

Site URL: https://www.versed-goods.com/shop/do-not-purchase

Hello,

I would like to know if anyone would be able to help me get two form fields to disappear then reappear based on a radio choice. The form that this would happen in can be found on https://www.versed-goods.com/shop/do-not-purchase

What i want to happen is the uploader and the selector would both be hidden on page load, then one would appear based on which radio option you choose.

The code i have has a part where the uploader is hidden, if you run the commented out hide while the form is open in the inspector it will hide the upload field. This should be happening when it opens.

Here is the code i have:

<script>
//when the radio for uploading a product is clicked show the appropriate form field
  $(document).ready(function(){
    //get data
    var window = $('.sqs-modal-lightbox');
    var uploader = $('.sqsf-uploader');
    
    //hide form fields
    uploader.hide();
    //$('.sqsf-uploader').hide();
    // selector.hide();
    
    //add class to file input field
    
      $(document).ready(function(){
          $("input[type='radio']").click(function(){
              var radioValue = $("input[name='radio-yui_3_17_2_1_1595106168164_103612-field']:checked").val();
              if(radioValue == 'yes'){
                  selector.hide();
                  uploader.show();
              } else {
                selector.show();
                uoloader.hide();
              }
          });
      });
  });
</script>

Link to comment
  • Replies 0
  • Views 769
  • Created
  • Last Reply

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.