# Counting radio button value

**URL:** <https://forum.kintone.dev/t/counting-radio-button-value/111>\
**Category:** General\
**Created:** [June 7, 2019, 7:55am UTC](https://forum.kintone.dev/t/counting-radio-button-value/111 "2019-06-07T07:55:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [June 7, 2019, 7:55am UTC](https://forum.kintone.dev/t/counting-radio-button-value/111/1 "2019-06-07T07:55:25Z")

</div>

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;

});  
})();

&nbsp;

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

thanks a lot!

---

<div class="post-metadata">

**Author:** ![legacy\_user](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/legacy_user/32/25_2.png) [@legacy\_user](https://forum.kintone.dev/u/legacy_user)\
**Post date:** [June 7, 2019, 5:21pm UTC](https://forum.kintone.dev/t/counting-radio-button-value/111/2 "2019-06-07T17:21:59Z")

</div>

Hi Suzette,

&nbsp;

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.

&nbsp;

▼ Plugin Select type form totalization

[https://github.com/kintone/SAMPLE-select-type-form-totalization](https://github.com/kintone/SAMPLE-select-type-form-totalization)

&nbsp;

Or&nbsp;

&nbsp;

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?

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

&nbsp;

▼ Creating Graphs from App Settings&nbsp;

[https://get.kintone.help/k/en/user/app\_settings/report.html](https://get.kintone.help/k/en/user/app_settings/report.html)

&nbsp;

Thanks.

Junko
