Avatar

Dropdown.selected

NDC ELOG

How do I check the value of field a if the value matches then field b will select the same value.

 

(function () {
"use strict";
kintone.events.on('app.record.detail.show', function (event) {


var textField = kintone.app.getFieldElements('textfield');
var dropdown = document.getElementsByName("getdr").value;

for (var i in dropdown) {
if (textField .value.match('12')) {
i.selected(value.match('12'));
}
}
});
})();

 

Follow 3 followers
0

5 comments

Avatar
Sean Tachibana 0 votes

Hi NDC,

Do you want to determine if A and B are the same?
Here is a sample with that assumption, but I don't think the if statement is the problem here, so this would not be what you are trying to do in the first place.

If you want to make sure that field A and field B matches, you can do so by
event object and compare them using an if statement.

kintone.events.on("app.record.detail.show", function(e) {




if(e.record.text.value === e.record.dropdown.value){

//The process if it matches

}

})

In the current process, it seems like you are trying to get the values using kintone.app.getFieldElements.
However, if you want to use field values in an event, it is better to use an event object.

Event objects:

Hopefully, this helps.
0
Comment actions Permalink
Avatar
NDC ELOG 0 votes

Hi Sean Tachibana,

I want the value of the dropdown to automatically select according to the value of the text property, if the element is the same.

 

Text A  : input: value 12 or 12K

DropDown B: value : 12K, 13G,14R ,15P

------------------------------------------

Result: Dropdown selected(auto when run app): 12K

0
Comment actions Permalink
Avatar
NDC ELOG 0 votes

Hi Sean Tachibana,

Maybe you do not understand, so sorry,

please see this picture.

text field: keyboard input ( ex: 07)

dropdown value: 01,02,03,04,05,06,07,08,09,10,11,12

Thanks you!

0
Comment actions Permalink
Avatar
Yuzo Arai 0 votes

Hi NDC,

I just made a sample code of what you want to do.

Please use it as your reference.

(function() {
'use strict';
var events=['app.record.detail.show','app.record.create.show','app.record.create.change.Text'];
           // 'app.record.edit.change.Text', 'app.record.create.submit.success'];


kintone.events.on(events, function(event) {
    var record = event.record;
    var check = record['Text']['value'];

    if (check.indexOf("Text") !== "") {
     record['Drop_down']['value'] = check;
    
   return event;
}
});
})();
0
Comment actions Permalink
Avatar
NDC ELOG 0 votes

Hi Yuzo Arai,

i got it,

Thanks you so much.

Let’s make this day beautiful !

0
Comment actions Permalink