0
votes

http://skifimba.hostfree.pw/

This is my website. I'm noob in php/js and I want the following thing:

On the page I have added Request button (woocommerce) for products and when it's clicked a Contact form pops up. I want to echo the product name in <p></p> tags in the contact form. Anyone have an idea how this can be done?

Button locations

First button

Second button

1

1 Answers

0
votes

All you have to do is add a click handler on the request button, find the text of the 'h3', and set the modal form's "name" field value to that.

Take this JavaScript for example

jQuery(document).ready(function($){
    // When the Request button is clicked
    $('.request-form-btn').on('click', function(){
        // Set 'title' to the closest product's h3 text
        var title = $(this).closest('.prod-i').find('h3').text();

        // Set the value of the "name" field to the title we got above.
        $('[name="modal_name"]').val( title );
    });
});

It appears you're using a premium theme, so add this to the "Custom/Body/Footer" scripts section of the website if there is one, otherwise you'll need to use one of the many "Header/Footer" script plugins that are available.

You can test this by pasting the JavaScript into the dev tools console on that page.