# フォームブリッジ Kviewerルックアップ ボタンで入力値を表示

**URL:** <https://community.cybozu.dev/t/topic/5815>\
**Category:** kintone 開発相談\
**Created:** [2022 年 3 月 17 日午後 5:22 UTC](https://community.cybozu.dev/t/topic/5815 "2022-03-17T17:22:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account1550](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@Legacy\_Account1550](https://community.cybozu.dev/u/Legacy_Account1550)\
**Post date:** [2022 年 3 月 17 日午後 5:22 UTC](https://community.cybozu.dev/t/topic/5815/1 "2022-03-17T17:22:36Z")

</div>

**背景・実現したいこと**

Kviewerルックアップを使用して、フォームブリッジから検索したレコードのみを表示させるというフォームを作成しています。 検索してKviewerルックアップでレコードを取得後、フォーム内にボタンを設置し、クリックしたら同じフォーム内のフィールドに入力されているURLにリンクしたいと考えています。ボタンクリックとリンク表示が繋がらず、どうしたら良いかわかりません。初心者で申し訳ありませんが、教えていただけると幸いです。

**エラー情報** （開発者ツールのコンソール）

Uncaught TypeError: checkbutton.getElementsByTagName(…)[0] is undefined

**利用したソースコード**

(function() {

&nbsp; &nbsp; “use strict”;

&nbsp; &nbsp;

&nbsp; &nbsp; //[https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js](https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js)

&nbsp; &nbsp; $(document).ready(function() {

&nbsp; &nbsp; $(“#button”).click(function() {

&nbsp; &nbsp; &nbsp; &nbsp; var checkbutton = fb.getElementByCode(‘check\_box’);

&nbsp; &nbsp; &nbsp; &nbsp; checkbutton.getElementsByTagName(‘checkbox’)[0].value = 1;

&nbsp; &nbsp; });

&nbsp; &nbsp; });

&nbsp; &nbsp;

&nbsp; &nbsp; fb.events.form.mounted.push(function(state){

&nbsp; &nbsp; fb.getElementByCode(‘label’).innerHTML = ‘\<button id=“button”\>PopUp\</button\>’;

&nbsp; &nbsp; return state;

&nbsp; &nbsp; });

&nbsp; &nbsp;

&nbsp; &nbsp; fb.events.fields.check\_box.changed.push(function (state) {

&nbsp; &nbsp; &nbsp; &nbsp; const phone\_num = state.record[‘driver\_phone’].value;

&nbsp; &nbsp; &nbsp; &nbsp; location.href(phone\_num);

&nbsp; &nbsp; &nbsp; &nbsp; return state;

&nbsp; &nbsp; &nbsp; });

&nbsp; &nbsp; })();

---

<div class="post-metadata">

**Author:** ![Legacy\_Account2229](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Legacy\_Account2229](https://community.cybozu.dev/u/Legacy_Account2229)\
**Post date:** [2022 年 3 月 18 日午前 2:58 UTC](https://community.cybozu.dev/t/topic/5815/2 "2022-03-18T02:58:24Z")

</div>

Teckwahさん

こんにちは。

&nbsp;

意図されていることと違っているかもしれませんが

ボタンをクリックしたら、リンクを開くということであれば以下のように書けます。

addEventListenerでクリックイベントを定義することができます。

```
fb.events.form.mounted = [function(state) {

const button = document.createElement('button');
button.textContent = 'リンクを開く'
button.addEventListener('click', function() {
location.href = 'https://www.google.com/';
});

fb.getElementByCode('label').appendChild(button);

}];

```

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1550](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@Legacy\_Account1550](https://community.cybozu.dev/u/Legacy_Account1550)\
**Post date:** [2022 年 3 月 18 日午前 7:37 UTC](https://community.cybozu.dev/t/topic/5815/3 "2022-03-18T07:37:16Z")

</div>

koichiさま

お世話になっております。

早速ご教示いただきありがとうございます。

ボタン作成も色々な方法があるのですね。

やりたいこととは若干異なりますが、勉強になりました。

もう少しJavascriptがわかるようになったら、再挑戦してみます！

&nbsp;

---

<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:** [2024 年 9 月 27 日午前 4:13 UTC](https://community.cybozu.dev/t/topic/5815/4 "2024-09-27T04:13:51Z")

</div>

クローズされました: 2024 年 9 月 27 日午前 4:13 UTC

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