1

I am having an issue understanding how to perform calculations based on values from textboxes and a JSON.

I have textboxes:

<cms:input name="fat" id="fat" type="bound" class="form-control" placeholder="FAT" />
<cms:input name="snf" id="snf" type="bound" class="form-control" placeholder="SNF" />
<cms:input name="rate" id="rate" type="bound" class="form-control" placeholder="Rate" tabIndex="-1" readonly="readonly" />
<cms:input name="quantity" id="quantity" type="bound" class="form-control" placeholder="Quantity" />
<cms:input name="payable_amount" id="payable_amount" type="bound" class="form-control" placeholder="Payable Amount" tabIndex="-1" readonly="readonly" />

I have a json (sample) as:

{
"cow": [{
    "fat": 1,
    "snf": 1,
    "rate": 10
}, {
    "fat": 2,
    "snf": 2,
    "rate": 20
}],
"buff": [{
    "fat": 1,
    "snf": 1,
    "rate": 10
}, {
    "fat": 2,
    "snf": 2,
    "rate": 20
}]

}

The fat and snf values will be filled in manually by the user. Once these values are available, depending on the FAT-SNF pair a corresponding rate needs to be looked up from the json and updated into the rate input. The user will then fill in the quantity input. on change or blur of the quantity input, the payable_amount input needs to be updated with the value as (rate * quantity).

How can this be achieved.

Regards, Aashish

0 Answers0