# Dropdown.selected

**URL:** <https://forum.kintone.dev/t/dropdown-selected/367>\
**Category:** General\
**Tags:** drop-down-field\
**Created:** [December 11, 2020, 8:11am UTC](https://forum.kintone.dev/t/dropdown-selected/367 "2020-12-11T08:11:15Z")\
**Posts on this page:** 6\
**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:** [December 11, 2020, 8:11am UTC](https://forum.kintone.dev/t/dropdown-selected/367/1 "2020-12-11T08:11:15Z")

</div>

How do I check the value of Field-A if the value matches, then Field-B will select the same value?

```javascript
(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'));  
}  
}  
});  
})();

```

---

<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:** [December 12, 2020, 4:40pm UTC](https://forum.kintone.dev/t/dropdown-selected/367/2 "2020-12-12T16:40:54Z")

</div>

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:

[https://developer.kintone.io/hc/en-us/articles/115003218073-Event-objects](https://forum.kintone.dev/hc/en-us/articles/115003218073-Event-objects)

Hopefully, this helps.

|

---

<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:** [December 13, 2020, 7:49am UTC](https://forum.kintone.dev/t/dropdown-selected/367/3 "2020-12-13T07:49:02Z")

</div>

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.

&nbsp;

Text A&nbsp; : input: value 12 or 12K

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

* * *

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

---

<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:** [December 16, 2020, 2:57am UTC](https://forum.kintone.dev/t/dropdown-selected/367/4 "2020-12-16T02:57:22Z")

</div>

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  
 ![](https://developer.kintone.io/hc/user_images/9K_TS1ZWGiKGZWJ7_cYCzQ.png)

Thanks you!

---

<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:** [December 16, 2020, 6:39pm UTC](https://forum.kintone.dev/t/dropdown-selected/367/5 "2020-12-16T18:39:34Z")

</div>

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;
}
});
})();
```

---

<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:** [December 17, 2020, 1:05am UTC](https://forum.kintone.dev/t/dropdown-selected/367/6 "2020-12-17T01:05:19Z")

</div>

Hi Yuzo Arai,

i got it,

Thanks you so much.

Let’s make this day beautiful !
