Sign In

Use your secure 256Local account to continue.

Sign In Create Member Account Create Business Account
Knock Em Down Tree Service
Deal Club Offer

Knock Em Down Tree Service

Latest Deals

document.addEventListener('DOMContentLoaded', function() {
    // Select all buttons that should trigger the coupon data population.
    // Replace '.your-coupon-button-class' with the actual CSS class you gave your button in Elementor.
    const couponButtons = document.querySelectorAll('.your-coupon-button-class'); 

    couponButtons.forEach(button => {
        button.addEventListener('click', function(event) {
            event.preventDefault(); // Prevents the button's default action (e.g., submitting the form prematurely)

            const card = this.closest('.coupon-card');
            if (card) {
                const data = card.querySelector('.coupon-data');
                const form = card.querySelector('form');

                if (data && form) {
                    // Pulling only the product title for testing
                    const productTitle = data.dataset.productTitle;
                    
                    // Assuming your Gravity Forms hidden field for the product title has the name "input_1"
                    // You must verify this in your Gravity Forms field settings.
                    const hiddenField = form.querySelector('input[name="input_1"]');
                    
                    if (hiddenField) {
                        hiddenField.value = productTitle;
                        console.log('Product title set to:', hiddenField.value); // For debugging: check the browser console
                    }
                }
            }
        });
    });
});