Skip to content
Discussion options

You must be logged in to vote

Hey @aberaldo

The subfield() supports the row number argument.

Try:

crud.field('features').onChange(function(field) {
    var i = 1;
    var total = 0;
    while ((crud.field('features').subfield(`subtotal`,i).value != undefined)) {
        var subtotal = crud.field('features').subfield(`subtotal`,i).value; //subfield() supports row number argument.
        console.log("subtotal",subtotal);
        total+=Number(subtotal);
        i++;
    }
    console.log("total",total);
}).change();

@pxpm can you suggest a better way to loop ?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aberaldo
Comment options

Answer selected by pxpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants