how to add new row in form grid using javascript (will trigger by a button) ?

Confluence User - 31 Oct, 2017

Hi there,

I have created a button to auto-generate the number of rows predefined by user into form grid.  I do checked there's a sample script - Add a new Row in Form Grid using script from Knowledge Base, anyhow I am not sure how to call it from my button, is it using onClick event?  

Would appreciate your advise.  Many thanks ahead.

Regards,

Wah Man

forms

1


01 Nov, 2017
confluenceUser
confluenceUser

Hi, based on the sample script, it think you first need to make it a function first as following, how to trigger this function is based on how and when you want the function is call.

function addRow() {
    // the field id is "entries"
    var field = FormUtil.getField("entries");
    var functionName = window[field.attr("id") + "_add"];
    if(typeof functionName === 'function') {
        var args = new Object();
        args['result'] = '{"amount":"1","category":"Medical","claim":"","purpose":"a","date":"11/18/2015","formattedAmount":"$ 1.00"}';
        functionName(args);
    }
}
RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print