Reply To: Setting value of radio inputs via button

Home Forums Quform WordPress Setting value of radio inputs via button Reply To: Setting value of radio inputs via button

#30022

adg_domme
Participant

Hi Alley,

thank you so much.

I’m going to share the code I’ve used:

jQuery(document).ready(function ($) {
    $('a[href="#anfrage"]').click(function () {
        var buttonText = $(this).text();
        if (buttonText == 'Einzelgarage') {
            $('.quform-popup-link-1').click();
            $('.quform-field-1_7_1').prop('checked', true);
            $('.quform-form-1').data('quform').goToPage(8);
        } else if (buttonText == 'Doppelgarage') {
            $('.quform-popup-link-1').click();
            $('.quform-field-1_7_2').prop('checked', true);
            $('.quform-form-1').data('quform').goToPage(8);
        } else if (buttonText == 'Großraumgarage') {
            $('.quform-popup-link-1').click();
            $('.quform-field-1_7_3').prop('checked', true);
            $('.quform-form-1').data('quform').goToPage(8);
        } else if (buttonText == 'Reihengarage') {
            $('.quform-popup-link-1').click();
            $('.quform-field-1_7_4').prop('checked', true);
            $('.quform-form-1').data('quform').goToPage(8);
        } else {
            $('.quform-popup-link-1').click();
        }
        return false;
    });
});

What this does: I have several anchor links (#anfrage) that open quform in a popup by default. If any of the given strings (text of the link/button) is matched, the code checks the corresponding radio button and advances to the next step of the form. If the user has progressed further and reopens the form through a matching link, the first radio button will be updated if necessary and the form “begins” at the next step again (second step in this case), but the user can still see the selection he/she made for the upcoming steps.

Exactly what I wanted. I think this case can be considered solved. 🙂

Be inspired. © 2019 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy