Andrew-Sepic
Andrew-Sepic

Reputation: 553

Trigger Form Submit in Multipage Gravity form from first Page

I have a multi-page gravity forms form with conditional logic setup here

If the user selects on option in a set of radio buttons I'd like to replace the 'next page' button of the form with the 'Submit' button which is not rendered on that current page.

I've approached this a few ways, including getting the onClick and onKeypress values from the submit button and applying them to the next page button, But that gets messy when a user decides to toggle another radio button where the 'Next' page button should be unaltered. I've tried to use .replaceChild() and .insertBefore() so that I could just swap the buttons, or hide the 'Next' button and show the 'Submit' button, but I receive a parentNode.replaceChild is not a function error on both of those attempts.

Am I going about this in an appropriate way? And/or what is happening with the 'is not a function' warnings?

    function formLove() {

      // disable button until home-size is selected
      var nextbutton = document.getElementById("gform_next_button_13_61");
      nextbutton.disabled = true;

      // Survey Type Selection &
      $('li.survey-type input[type=radio]').change(function() {
        nextbutton.disabled = false;

        if (this.value == 'Give Me a Call') {
            console.log('Give Me A Call!');
            nextbutton.value = 'Submit';

            // Make form submit happen from page #1
            var formSubmit = document.getElementById("gform_submit_button_13");
            var parentNode = document.querySelectorAll('#gform_page_13_1 .gform_page_footer');
            parentNode.replaceChild(formSubmit, nextbutton);

        }
        else if (this.value == 'Self-Service Virtual Estimate') {
            console.log('It\'s Yembo Baby!');
            nextbutton.value = 'Start Virtual Survey';
        }
        else if (this.value == 'Guided In-Home or Virtual Estimate') {
            console.log('Get me an appointment!');
            nextbutton.value = 'Next';
        }
      });

    }

Thanks!

Upvotes: 0

Views: 1981

Answers (1)

joshmoto
joshmoto

Reputation: 5108

Can you perhaps use Enable Page Conditional Logic on your page break to handle the radio button options?

So if the following form pages never existed because of the radio options conditional logic, then would this next button not default back to the submit button?

enter image description here

Upvotes: 1

Related Questions