• Resolved hheyhey568

    (@hheyhey568)


    Hi,

    Is there a way where I can able to assign pre-defined value based on another input field and give choice to user to either use the pre-defined value or change it ?

    For example : Fieldname1 is number field and fieldname2 is also number field. Now assign the fieldname1=fieldname2 but if user want to change value of fieldname1 to 100 then that of user value ( 100 in this case) is used as an input in the calculation.

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

    (@codepeople)

    Hello @hheyhey568

    In the current version of the plugin would be required some of code. Please, insert an “HTML Content” field in the form with the following piece of code as its content:

    
    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
    jQuery('[id*="fieldname1_"]').val(jQuery('[id*="fieldname2_"]').val()).change();
    });
    </script>
    

    and that’s all.
    Best regards.

    Thread Starter hheyhey568

    (@hheyhey568)

    Thank you.. This is working fine.

    Can I have another possibility as follows?

    Lets say after opening the form , user change the value of fieldname2 to 200. I want that the moment user change the value of fieldname2 to 200 , the value of fiedname1 also change automatically to the value of fieldname2( 200 in this case). and it also allows user to manually change the value of fieldname1 if required.

    Plugin Author codepeople

    (@codepeople)

    Hello @hheyhey568

    If you want the value of the fieldname1 field varies every time the user edit the value of the fieldname2 field, please, use the piece of code:

    
    <script>
    jQuery(document).on('change', '[id*="fieldname2_"]', function(){
    jQuery('[id*="fieldname1_"]').val(this.value).change();
    });</script>
    

    Best regards.

    Thread Starter hheyhey568

    (@hheyhey568)

    Thanks a lot.

    Thread Starter hheyhey568

    (@hheyhey568)

    What if value of more than one fieldname’s field are to be varied every time the user edit the value of the fieldname2 field?

    Plugin Author codepeople

    (@codepeople)

    Hello @hheyhey568

    The code I sent you in the previous entry covers the behavior described.

    Best regards.

    Thread Starter hheyhey568

    (@hheyhey568)

    I mean to say as follows:

    <script>
    jQuery(document).on(‘change’, ‘[id*=”fieldname2_”]’, function(){
    jQuery(‘[id*=”fieldname1_”,”fieldname3_”,”fieldname4_”]’).val(this.value).change();
    });</script>

    If user change the value of fieldname2 then value of fieldname1, fieldname3 and fieldname4 also changes .

    Plugin Author codepeople

    (@codepeople)

    Hello @hheyhey568

    The code would be as follows:

    
    <script>
    jQuery(document).on('change', '[id*="fieldname2_"]', function(){
    jQuery('[id*="fieldname1_"]').val(this.value).change();
    jQuery('[id*="fieldname3_"]').val(this.value).change();
    jQuery('[id*="fieldname4_"]').val(this.value).change();
    });</script>
    

    Best regards.

    Thread Starter hheyhey568

    (@hheyhey568)

    thanks a lot..perfect.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Predefined Value based on another number field’ is closed to new replies.