Skip to content

Instantly share code, notes, and snippets.

@denlunev
Created July 23, 2020 21:59
Show Gist options
  • Save denlunev/6631ef578d1408ed1d147a00c6a0aca1 to your computer and use it in GitHub Desktop.
Save denlunev/6631ef578d1408ed1d147a00c6a0aca1 to your computer and use it in GitHub Desktop.
Vollective 54
var hubSpotProductField = 'product_selector';
var dfProduct = document.getElementById('df_products');
document.getElementById('df_products').parentElement.parentElement.parentElement.parentElement.style.display = 'none'
var products = document.querySelectorAll('[name=' + hubSpotProductField +']');
Array.prototype.forEach.call(products, function(radio) {
radio.addEventListener('change', function(event){
if(event.target.value == 'Product 1'){
dfProduct.selectedIndex = 0;
}else if(event.target.value == 'Product 2'){
dfProduct.selectedIndex = 1;
}else if(event.target.value == 'Product 3'){
dfProduct.selectedIndex = 2;
}
dfProduct.dispatchEvent(new Event('change'));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment