LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Sunday, December 31, 2017

ラジオボタンを選択状態にする

JavaScriptでラジオボタンを選択状態にする





ラジオボタンを作る では
<input type="radio" name="radio1" id="radio1_1" value="yes" checked="checked">
のようにラジオボタンに直接checkedを入れました

今回はJavaScriptでcheckedにしています
document.getElementById("radio1_1").checked = "checked";




コード.gs
function doGet() {
  return HtmlService.createHtmlOutputFromFile("index");
}
意訳
この機能がやること
指定したHTMLファイルを表示する




index.html
<!DOCTYPE html>
<html>
<body>
  <input type="radio" name="radio1" id="radio1_1" value="yes">
  <label for="radio1_1">はい</label>
  <br>
  <input type="radio" name="radio1" id="radio1_2" value="no">
  <label for="radio1_2">いいえ</label>
  <script>
    document.getElementById("radio1_1").checked = "checked";
  </script>
</body>
</html>
意訳
これはHTML5文書です


1つ目のラジオボタンを作る
それにラベルを付ける

2つ目のラジオボタンを作る
それにラベルを付ける

1つ目のラジオボタンを選択する






Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...