• Resolved zukenstein

    (@zukenstein)


    Hi still in awe of this plugin and the support!!!

    I am using this duplicating function with a dropdown field

    (function(){
    if(fieldname16==0 )return getField(27).setVal('0');
    if(fieldname16==1 )return getField(27).setVal('1');
    if(fieldname16==2 )return getField(27).setVal('2');
    })();

    to duplicate the selection to another dropdown field, which works great. But I would like to allow the same change to happen the other way as well so have put another calculated field in like below as well

    (function(){
    if(fieldname27==0 )return getField(16).setVal('0');
    if(fieldname27==1 )return getField(16).setVal('1');
    if(fieldname27==2 )return getField(16).setVal('2');
    })();

    But it only works one way, is there something I need to add to get it working both ways?

    Many thanks!

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

    (@codepeople)

    Hello @zukenstein

    Please, edit the equations as follows:

    
    (function(){
    if(fieldname16==0 ) getField(27).setVal('0');
    if(fieldname16==1 ) getField(27).setVal('1');
    if(fieldname16==2 ) getField(27).setVal('2');
    })();
    

    and

    
    (function(){
    if(fieldname27==0 ) getField(16).setVal('0');
    if(fieldname27==1 ) getField(16).setVal('1');
    if(fieldname27==2 ) getField(16).setVal('2');
    })();
    

    If the issue persists, you should indicate the URL to the form’s page to check these equations in action.

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Hi Thanks
    I put the dropdowns and equations into a separate page with two dropdowns and two calculation fields using the formulas as you put them so you could see it but it will not load it just keeps on hanging and crashing the page and preview.

    Works fine with just one calculation field and the formula working one way, either with the ‘return’ or without

    thanks

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    Please, send me the links to the pages to check the equations in action.

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Hi have put link below but it will just hang here, give it a try from your end

    Thanks

    https://81b.co.uk/cff-test-page/

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    The URL https://81b.co.uk/cff-test-page/ returns a 404 Error, page not found.

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Sorry was set to private, try now

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    You’ve generated an infinite loop on your form. The setVal operation assigns a value to the field and triggers an onchange event, and this action provokes the equations that use the field to be evaluated.

    This means, the evaluation of the equation in the fieldname4 field triggers the equation in the fieldname2 field, but the equation in the fieldname2 field triggers the equation in the fialdname4 field in an endless process.

    The alternatives.

    Edit the equation in the fieldname2 as follows:

    
    (function(){
    var f = getField(3).jQueryRef();
    if(fieldname1 == 0 ) f.find('[value="0"]').prop('selected', true);
    if(fieldname1 == 1 ) f.find('[value="1"]').prop('selected', true);
    if(fieldname1 == 2 ) f.find('[value="2"]').prop('selected', true);
    })();
    

    And edit the equation in the fieldname4 as follows:

    
    (function(){
    var f = getField(1).jQueryRef();
    if(fieldname3 == 0 ) f.find('[value="0"]').prop('selected', true);
    if(fieldname3 == 1 ) f.find('[value="1"]').prop('selected', true);
    if(fieldname3 == 2 ) f.find('[value="2"]').prop('selected', true);
    })();
    

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    That works beautifully thanks very much ??

    I have another question about if its possible to have the fieldset be expanded by default instead of collapsed, but still make it collapsible?
    Should I start another thread for that question to keep this one on point?

    Thanks very much for your swift and detailed responses as always ??

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    Insert an “HTML Content” field in the form with the piece of code:

    
    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
    fbuilderjQuery('.cff-collapsible').removeClass('cff-collapsed');
    });
    </script>
    

    And that’s all.
    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Thats great thanks, is there a way to make it only work on specific fieldsets as I think what you have shown will do them all in the form wont it?

    Sorry for all the questions!

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    You can assign a custom class name to the form, for example, my-container

    The class names are assigned to the field through their attributes: “Add CSS Layout Keywords”

    And then, the code to use would be similar to:

    
    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
    fbuilderjQuery('.my-container').removeClass('cff-collapsed');
    });
    </script>
    

    I’m sorry, but if you need additional custom behaviors, you should contact me through my private website: Custom coding Service

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Ok will do, thank you very much for what you have done, I’ll see how it goes. I will be contacting you in the new year for some custom work anyway.

    I hope you and your family have a safe and happy Christmas and New Year break.

    Regards

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Duplicating field input to another and vice versa’ is closed to new replies.