Streaming live at 10am (PST)

Onchange event from product option select

Morning
I’m new to webflow and finding it a little troublesome to produce what I want. Our previous site was created in wix which I managed to sort eventually but our new site is in webflow. All I need to do is append a link to a button on the site depending on the products SKU chosen. This alters depending on the size selected from a select which is pulling options from the product database. I have added the custom attribute onchange with the value getPlanID() and added my getPlanID() function to the product page template header

<script>

function getPlanID {
	var productID = sku;
  alert(productID); 
	switch (productID) {
  		case 1:
  			document.getElementById("button1").link = "https://payment.mattressclub.co.uk/S4/setup.html?plan=P-4A3606200T858525MMGHC7LQ";
  			break;
  		case 2:
  			document.getElementById("button1").link = "https://payment.mattressclub.co.uk/S4/setup.html?plan=P-9WC71578R4899282YMGHDC2Y";
  			break;
  		case 3:
  			document.getElementById("button1").link = "https://payment.mattressclub.co.uk/S4/setup.html?plan=P-0R3660315H536983HMGHDDRQ";
  			break;
  		case 4:
  			document.getElementById("button1").link = "https://payment.mattressclub.co.uk/S4/setup.html?plan=P-3U997098MK720664MMGHDEEA";
  			break;
  }

}
</script>

I haven’t even got as far as testing if the code appends to the button as the alert doesnt appear so I assume the code isnt running when the option is changed.

Many thanks chris


Here is my site Read-Only: LINK
(how to share your site Read-Only link)