Avatar

Counting radio button value

Suzette Maala

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!

Follow 2 followers
0

1 comment

Avatar
Junko Werner 0 votes
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
 
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 
 
Thanks.
Junko
0
Comment actions Permalink