0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[GAS] input要素のvalue属性に複数の値を設定する

Posted at

やりたいこと

GASで作成したHTMLにチェックボックスをチェックしたらスプレッドシート上の関連する複数の値を関数に渡したいが、input要素のvalue属性には、複数の値は設定できない><

解決方法

複数の値をカンマ(,)区切りなどで単体の値として読み込み、
取り出すときにカンマ(,)区切りで取り出す

コード

    const itemHoge = item['アイテム1'];
    const itemFuga = item['アイテム2'];
    const itemPiyo = item['アイテム3'];
    <input type="checkbox" value="${itemHoge},${itemFuga},${itemPiyo}" onchange="inputChange(this.value)">;

function inputChange(value){
    result = value.split(",");
    console.log("itemHoge = result[0]");
    console.log("itemFuga = result[1]");
    console.log("itemPiyo = result[2]");
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?