Reply To: Modify a field value based on select option change

Home Forums Quform WordPress Modify a field value based on select option change Reply To: Modify a field value based on select option change

#32212
Labella
Participant

Of course! This is a page containing the form (you must scroll down and click on “ISCRIZIONE” in order to show it): https://www.labellaschool.it/corsi-professionali-musica/corso-di-arrangiamento-e-produzione-di-andrea-pellegrini/

I write here the entire code that I have in custom JS panel, maybe there is something wrong somewhere else! But the other forms are all running without errors, so I guess the code regarding the other forms is ok:

 jQuery(function ($) {
 
    var $select1 = $('.quform-field-11_150'); 
    $select1.on('change', function () {
        var value = $select1.val(); 
        if (value=='Online') {
            $('.quform-field-11_151').val($('.quform-field-11_147').val());   
        }
        if (value=='Presenza') {
            $('.quform-field-11_151').val($('.quform-field-11_154').val()); 
        }
     }).change();
    
    $('#titolo').text($('.quform-field-8_27').val());
    $('#orario').text($('.quform-field-8_19').val());    
    $('#inizio').text($('.quform-field-8_20').val());
    $('#durata').text($('.quform-field-8_21').val());
    $('#frequenza').text($('.quform-field-8_22').val());
    $('#lezioni').text($('.quform-field-8_23').val());
    $('#sede').text($('.quform-field-8_32').val());
    $('#costo').text($('.quform-field-8_29').val());

    $('#titolo').text($('.quform-field-10_27').val());
    $('#orario').text($('.quform-field-10_19').val());    
    $('#inizio').text($('.quform-field-10_20').val());
    $('#durata').text($('.quform-field-10_21').val());
    $('#frequenza').text($('.quform-field-10_22').val());
    $('#lezioni').text($('.quform-field-10_23').val());
    $('#sede').text($('.quform-field-10_32').val());
    $('#costo').text($('.quform-field-10_29').val());
    
    $('#worario').text($('.quform-field-10_46').val());    
    $('#winizio').text($('.quform-field-10_47').val());
    $('#wdurata').text($('.quform-field-10_48').val());
    $('#wfrequenza').text($('.quform-field-10_49').val());
    $('#wlezioni').text($('.quform-field-10_50').val());
    $('#wcosto').text($('.quform-field-10_51').val());

    $('.quform-field-1_139').val(Math.round($('.quform-field-1_102').val()/20)*10);
    

    var calculate = function () {
        var total = 0;
        var stotal = 0;
        var conto = 0;
        
            var corso = $('.quform-field-3_57').val();
            if (corso) {
                if ($.inArray('Suono', corso) > -1) {
                    total += parseInt($('.quform-field-3_83').val());
                    conto+=1;
                }
                if ($.inArray('Mixaggio', corso) > -1) {
                    total += parseInt($('.quform-field-3_84').val());
                    conto+=1;
                }
                if ($.inArray('Logic', corso) > -1) {
                    total += parseInt($('.quform-field-3_85').val());
                    conto+=1;
                }
                if ($.inArray('Elettronica1', corso) > -1) {
                    total += parseInt($('.quform-field-3_86').val());
                    conto+=1;
                }
                if ($.inArray('Elettronica2', corso) > -1) {
                    total += parseInt($('.quform-field-3_87').val());
                    conto+=1;
                }
                if ($.inArray('Elettronica3', corso) > -1) {
                    total += parseInt($('.quform-field-3_88').val());
                    conto+=1;
                }
                if ($.inArray('Protools', corso) > -1) {
                    total += parseInt($('.quform-field-3_89').val());
                    conto+=1;
                }
                if ($.inArray('Producer', corso) > -1) {
                    total += parseInt($('.quform-field-3_90').val());
                    conto+=1;
                }
                if ($.inArray('Arrangiamento', corso) > -1) {
                    total += parseInt($('.quform-field-3_91').val());
                    conto+=1;
                }
                if ($.inArray('Tecnico-Live', corso) > -1) {
                    total += parseInt($('.quform-field-3_92').val());
                    conto+=1;
                }
            
            }
        

        if(conto<3) {
             total='';
             $('#form-total').text('Valore corsi selezionati: (Seleziona un minimo di 3 corsi)');
             $('#form-stotal').text('');
         } else {            
             stotal=Math.round(total/1000*(94.5-(conto*1.95)))*10;
             $('#form-total').text('Valore corsi selezionati: '+total+'€');
             $('#form-stotal').text('Costo finale con sconto: '+stotal+'€');
         }
        $('.quform-field-3_132').val(stotal);
        $('.quform-field-3_144').val(Math.round(stotal/30)*10);
    };

    // Calculate on page load
    calculate();
 
    // Recalculate when these select menus are changed
    $('.quform-field-3_57').change(calculate);
});

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