• Resolved tilou

    (@tilou)


    Hi,

    Thanks again for this great plugin.
    I would like to know if it would be possible to create a drop-down menu to automatically populate other number fields. Thus, when a user chooses an item from the drop-down menu, 5 number fields are automatically filled according to the drop-down selection.

    Thanks
    Jean-Lou

    • This topic was modified 5 years ago by tilou.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @tilou

    There are different alternatives, that I’ll try to describe with an hypothetical example:

    Assuming the DropDown field is the fieldname3, and the other three fields are: fieldname4, fieldname7 and fieldname9

    If the choice selected in the fieldname3 is: 1, then, assign the values:

    fielname4=5
    fieldname7=12
    fieldname9=1

    and if the choice selected in the fieldname3 is: 2 assign the values:

    fielname4=8
    fieldname7=3
    fieldname9=4

    Note: the fields and values are hypothetical, only to describe the process.

    First alternative:

    – Insert a “HTML Content” field in the form with the following piece of code, as its content:

    
    <script>
    jQuery(document).on('change', '[id*="fieldname3_"]', function(){
        var $ = jQuery,
            v = $(this).val();
        if(v==1)
        {
            $('[id*="fieldname4_"]').val(5);
            $('[id*="fieldname7_"]').val(12);
            $('[id*="fieldname9_"]').val(1);
        }
        if(v==2)
        {
            $('[id*="fieldname4_"]').val(8);
            $('[id*="fieldname7_"]').val(3);
            $('[id*="fieldname9_"]').val(4);
        }
    });
    </script>
    

    Second alternative, using a calculated field:

    – Insert a calculated field in the form to be used as auxiliary, and associate to it the following equation:

    
    (function(){
        var v = fieldname3;
        if(v==1)
        {
            getField(4).setVal(5);
            getField(7).setVal(12);
            getField(9).setVal(1);
        }
        if(v==2)
        {
            getField(4).setVal(8);
            getField(7).setVal(3);
            getField(9).setVal(4);
        }
    })()
    

    Best regards.

    Thread Starter tilou

    (@tilou)

    Thanks for your help. It is changing the values but on my site, in particular, it is not affecting the visual (type size).

    Thread Starter tilou

    (@tilou)

    The second method is working fine!

    Plugin Author codepeople

    (@codepeople)

    Hello @tilou

    I’ve visited your website and the texts at left are being updated too, when I modify the values at right. In any case this behavior is not exactly part of the plugin, you are talking about your own code.

    If you need help to implement your project you should contact us through our website: Contact Us

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Autofill form from dropdown’ is closed to new replies.