Jump to content

Conditional Forms on Product Form Popup

Recommended Posts

Site URL: https://www.americangardenhouse.com/products/o-sweet-viola

I'm trying to create an a conditional form (in this case it would be on the additional product form). After selecting the product variants and then clicking "Add to Cart" the popup product form displays with two radio inputs. If "Yes" is selected, I want the additional product form fields to display (currently hidden CSS) and if "No" then an html message to appear prompting the customer to click the product form "Add to Cart" button. 

 

<style>
	#textarea-yui_3_17_2_1_1585523845981_190824,
  	#address-yui_3_17_2_1_1585523845981_456969,
  	#email-yui_3_17_2_1_1585523845981_459960,
  	#phone-yui_3_17_2_1_1585523845981_461162 {
      display: none;
  }
</style>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
	$('#radio-yui_3_17_2_1_1585593158170_218442 input:radio').click(function() {
    	selection = $(this).val();
      	if (selection == 'Yes') {
          $('.form-item').show;
        }
      else
        if (selection == 'No') {
          $('form').html('Maybe Next Time. Please complete adding this product to your card by clicking "Add to Cart"');
        }
    });
</script>

The CSS is loaded using code injector into the page header and the script is in the footer. AJAX is currently disabled.

Problem is, the click event is not working. Any help would be greatly appreciated. Thank you!
 

Screen Shot 2020-03-30 at 10.27.47 PM.png

Edited by chapmanf16
More Information
Link to comment
  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

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.