Counting radio button value

hi! i’m creating a form in my app, and I wanted to count the radio button result each time one is chosen. for my usecase, my radio button has two values, “OK” and “NG” each time one of these values is chosen, I would like to show how many times it is chosen after the form is submitted. here is my code

(function() {
“use strict”;

var RADIOBUTTON = “inspect” //field code of dropdown field
var RADIO_VALUE1 = “OK”; //ok option
var RADIO_VALUE2 = “NG”; //ng option
var OKCOUNT = “okcnt”; //field code of ok qty
var NGCOUNT = ‘ngcnt’ //field code of ng qty

kintone.events.on([“app.record.create.show”, “app.record.edit.show”], function(showevent){
showevent.record[RESULT][‘disabled’] = true;
return showevent;
})

kintone.events.on([“app.record.create.submit”,“app.record.edit.submit”], function(submitevent){
var record = submitevent.record;
//var whatvalue = record[RADIOBUTTON].value;

if (record[RADIOBUTTON.value] === RADIO_VALUE1){
record[OKCOUNT].value += 1;
}

else(record[RADIOBUTTON.value] === RADIO_VALUE2){
record[NGCOUNT] += 1;
}

return submitevent;

});
})();

 

pls help me if there is something wrong in my code.

thanks a lot!

Hi Suzette,

 

Do you have multiple radio button fields in one record and would like to count how many “OK” and “NG” values are chosen and display each result?

I can try to look at your code but I found the following plug-in.

 

▼ Plugin Select type form totalization

https://github.com/kintone/SAMPLE-select-type-form-totalization

 

Or 

 

You have one radio button in each record and would like to count how many records have the value of the radio button as “OK” and “NG” in your app?

 In this case, you can create a graph to summarize the data in an app by counting each radio button result.

 

▼ Creating Graphs from App Settings 

https://get.kintone.help/k/en/user/app_settings/report.html

 

Thanks.

Junko