# チェックボックスで表示・非表示

**URL:** <https://community.cybozu.dev/t/topic/3254>\
**Category:** kintone 開発相談\
**Created:** [2018 年 8 月 7 日午前 6:35 UTC](https://community.cybozu.dev/t/topic/3254 "2018-08-07T06:35:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account1999](https://avatars.discourse-cdn.com/v4/letter/l/aca169/32.png) [@Legacy\_Account1999](https://community.cybozu.dev/u/Legacy_Account1999)\
**Post date:** [2018 年 8 月 7 日午前 6:35 UTC](https://community.cybozu.dev/t/topic/3254/1 "2018-08-07T06:35:48Z")

</div>

初めて投稿します。  
javascript初心者です。

現在チェックボックスを使って、フィールドの表示・非表示を行いたいと考えています。

チェックボックスの「その他」の項目ににチェックが入れば「その他(文字列(1行))」のフィールドを表示し、  
チェックが外されれば、非表示にするようにしたいと思っています。

ラジオボタンではできたのですが、チェックボックスではうまくいきませんでした。

ソースは以下のように書いています。

(function() {  
“use strict”;  
kintone.events.on([‘app.record.create.show’,  
‘app.record.edit.show’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘app.record.create.change.チェックボックス’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘app.record.edit.change.チェックボックス’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘app.record.detail.show’], function(event){

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var record = event[‘record’];  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (record[‘チェックボックス’][‘value’] === ‘その他’) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kintone.app.record.setFieldShown(‘その他’, true);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;kintone.app.record.setFieldShown(‘その他’, false);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}  
&nbsp; &nbsp; &nbsp; &nbsp;return event;  
&nbsp; &nbsp; &nbsp; &nbsp;});  
})();

以上のように書いています。

ご教授していただけますと、幸いです。

よろしくお願いします。

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1896](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@Legacy\_Account1896](https://community.cybozu.dev/u/Legacy_Account1896)\
**Post date:** [2018 年 8 月 7 日午前 7:46 UTC](https://community.cybozu.dev/t/topic/3254/2 "2018-08-07T07:46:37Z")

</div>

k\_chinen さん

ラジオボタンとチェックボックスではオブジェクトの構造が違うため、  
同じ書き方だとうまく動きません。  
[https://developer.cybozu.io/hc/ja/articles/202166330](https://developer.cybozu.io/hc/ja/articles/202166330)

修正するべき箇所はif分の条件式の部分だと思います。

配列の判定は下記リンク先のようなやり方で実装可能です。  
[https://qiita.com/koyopro/items/8faced246d0d5ed921e0](https://qiita.com/koyopro/items/8faced246d0d5ed921e0)

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1999](https://avatars.discourse-cdn.com/v4/letter/l/aca169/32.png) [@Legacy\_Account1999](https://community.cybozu.dev/u/Legacy_Account1999)\
**Post date:** [2018 年 8 月 8 日午前 2:58 UTC](https://community.cybozu.dev/t/topic/3254/3 "2018-08-08T02:58:30Z")

</div>

HANSAさん

ご回答ありがとうございます!！

なんとか実装することができました。

&nbsp;

ありがとうございました。

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1896](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@Legacy\_Account1896](https://community.cybozu.dev/u/Legacy_Account1896)\
**Post date:** [2018 年 8 月 8 日午前 4:13 UTC](https://community.cybozu.dev/t/topic/3254/4 "2018-08-08T04:13:10Z")

</div>

k\_chinen さん

実装できて良かったです！

オブジェクトや配列の扱いは面倒ですよね…

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1999](https://avatars.discourse-cdn.com/v4/letter/l/aca169/32.png) [@Legacy\_Account1999](https://community.cybozu.dev/u/Legacy_Account1999)\
**Post date:** [2018 年 8 月 8 日午前 5:36 UTC](https://community.cybozu.dev/t/topic/3254/5 "2018-08-08T05:36:18Z")

</div>

HANSAさん

ありがとうございます!!

まだまだ初心者なのでちんぷんかんぷんですが頑張っていきたいと思います。

&nbsp;

---

<div class="post-metadata">

**Author:** ![Legacy\_Account797](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Legacy\_Account797](https://community.cybozu.dev/u/Legacy_Account797)\
**Post date:** [2018 年 8 月 12 日午後 3:20 UTC](https://community.cybozu.dev/t/topic/3254/6 "2018-08-12T15:20:48Z")

</div>

ご参考までにですが、利用しやすいプラグインもあります。

ATTAZoo+の入力サポート+は今回のシーンに合うプラグインだと思います。

[https://www.jbat.co.jp/lp/attazoo.html/#about](https://www.jbat.co.jp/lp/attazoo.html/#about)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/cybozu/original/1X/d5c841c3c5a6cb66eed514001c1b45147c9e1f4f.png) [@system](https://community.cybozu.dev/u/system)\
**Post date:** [2025 年 3 月 12 日午前 4:39 UTC](https://community.cybozu.dev/t/topic/3254/7 "2025-03-12T04:39:22Z")

</div>

このトピックはベストアンサーに選ばれた返信から 3 日が経過したので自動的にクローズされました。新たに返信することはできません。
