• Resolved dongoldi

    (@dongoldi)


    Hi Codepeople

    First of all thank you for this wonderful plugin.

    I’m having fieldname2, fieldname3… and so on till fieldname11. I want to retrieve data of the last fieldname. For example, if someone fills field all the way till fieldname11, then retrieved value is of fieldname11. If someone fills field all the way till fieldname10, and fieldname11 is left null or without any value, then retrieved value is of fieldname10. If someone fills field all the way till fieldname9, and fieldname10 and fieldname11 is left null or without any value, then retrieved value is of fieldname9 and so on….

    (function(){

    if(fieldname11 === null) return fieldname10;

    if(fieldname10 === null) return fieldname9;

    if(fieldname9 === null) return fieldname8;

    if(fieldname8 === null) return fieldname7;

    if(fieldname7 === null) return fieldname6;

    if(fieldname6 === null) return fieldname5;

    if(fieldname5 === null) return fieldname4;

    if(fieldname4 === null) return fieldname3;

    if(fieldname3 === null) return fieldname2;

    if(fieldname2 === null) return fieldname1;

    return ”;

    })();

    Also how can i hide a fieldname until previous fieldname if filled. Thank you

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

    (@codepeople)

    Hello @dongoldi

    A simple solution would be to implement the equation as follows:

    (function(){
    let values = [fieldname11|r, fieldname10|r, fieldname9|r, fieldname8|r ,fieldname7|r, fieldname6|r, fieldname5|r, fieldname4|r, fieldname3|r, fieldname2|r, fieldname1|r];
    
    for(let i in values) if(value[i] != '') return values[i];
    })()

    Best regards.

    Thread Starter dongoldi

    (@dongoldi)

    Thank you so much.

    Thread Starter dongoldi

    (@dongoldi)

    Hey codepeople, hope you’re doing well.

    How do i get the last filled fieldname position. For example, these fieldnames are periods/years. Fieldname2 = 1st period/year, Fieldname3 = 2nd period/year, and so on till fieldname11 = 10th period/year. I just want the number of fieldnames filled by the user.

    Plugin Author codepeople

    (@codepeople)

    Hello @dongoldi

    You only need to modify a little the previous equation:

    (function(){
    let values = [fieldname11|r, fieldname10|r, fieldname9|r, fieldname8|r ,fieldname7|r, fieldname6|r, fieldname5|r, fieldname4|r, fieldname3|r, fieldname2|r, fieldname1|r],
    counter = 0;
    
    for(let i in values) if(value[i] != '') counter++;
    
    return counter;
    })()

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Returning Previous field value if successor field value isn’t filled’ is closed to new replies.