Reputation: 1
I'm creating a form in my app, and I wanted to count the radio button result each time one is chosen. For my use case, 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;
});
})();
When I ran the kintone app, it is not counting meaning there may be something wrong with the code.
pls help me on this, thanks!
Upvotes: 0
Views: 129
Reputation: 21
As I posted my comment at Kintone Developer Program previously,
https://developer.kintone.io/hc/en-us/community/posts/360001278862-Counting-radio-button-value
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/hc/en-us/articles/115001510828
Hope it helps.
Thanks.
Junko
Upvotes: 1