Formidable Forms – using JQuery to change the value of a text field based on changes to a dropdown list

If you wish to set the text field based on changes to a dropdown list.

For Formidable Forms, you can go to the Form’s Settings -> Customize HTML and add the Javascript code in the “After Fields” section.

The following source code will change the value of a text field based on changes to a dropdown list.

<script type="text/javascript">
jQuery(document).ready(function($){

    //when there is change in dropdown field 28
    $('select[name="item_meta[28]"]').change(function(){
        //print the value of field 28 to console
        console.log($('select[name="item_meta[28]"]').val())

        //if the value of field 28 is not empty
        if ($('select[name="item_meta[28]"]').val() != "")
        { 
            //set var1 to  the value of field 28 
            var var1 = $('select[name="item_meta[28]"]').val();
            //set the text field with key of pgr_symbol_db as that of field 28
            $("#field_pgr_symbol_db").val(var1);
        }
        else
            return;
 
    });

});
</script>

Leave a Comment

Your email address will not be published. Required fields are marked *