<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>webアプリ | nujonoa_blog</title>
	<atom:link href="https://nujonoa.com/category/%E4%BB%95%E4%BA%8B%E9%96%A2%E9%80%A3/google-spreadsheet/gas/web%E3%82%A2%E3%83%97%E3%83%AA/feed/" rel="self" type="application/rss+xml" />
	<link>https://nujonoa.com</link>
	<description>人生に役立つデータ集</description>
	<lastBuildDate>Thu, 21 Apr 2022 04:26:13 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://nujonoa.com/wp-content/uploads/2019/04/cropped-DSC00976-e1554456145409-32x32.jpg</url>
	<title>webアプリ | nujonoa_blog</title>
	<link>https://nujonoa.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【GASのWEBアプリ】で登録フォームを作る。</title>
		<link>https://nujonoa.com/make-a-registration-form-with-gas/</link>
					<comments>https://nujonoa.com/make-a-registration-form-with-gas/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Thu, 21 Apr 2022 11:00:00 +0000</pubDate>
				<category><![CDATA[webアプリ]]></category>
		<category><![CDATA[Webアプリ]]></category>
		<category><![CDATA[登録フォーム]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=13838</guid>

					<description><![CDATA[今回作ったもの↓ 下記の登録フォームです。 目次 GASで登録フォームを作る。index.htmljs1.htmlcss.htmlthankyou.html GASで登録フォームを作る。 doPost(e)でformから [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>今回作ったもの↓</p>



<p>下記の登録フォームです。</p>



<iframe src="https://script.google.com/macros/s/AKfycbyEuREe6NFjsiufwIC2BsYRF-EzN-ETHCe5O-TfjTWCxkHyZquoZIA4nczlHaafYqoRLQ/exec" width="600" height="900"></iframe>





<a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1lJxHTNf80wQJQHnZFJA4g2G15E5rmm1haWY0lmXR2l4/edit?usp=sharing" title="登録フォーム作成(css)" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-right cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img decoding="async" src="https://lh7-us.googleusercontent.com/docs/AHkbwyKwaSfVc4wfd_SBEar7bQrpHQUCR0yjlbRWWPQf7B3MLa7gcw4_uJ-jcKM9LjfE22yYt1tCf4vUy3AlSU9RWik_0Pn9KQB1zg2M7sTfX6LPAfykm2Vq=w1200-h630-p" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">登録フォーム作成(css)</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img decoding="async" src="https://www.google.com/s2/favicons?domain=https://docs.google.com/spreadsheets/d/1lJxHTNf80wQJQHnZFJA4g2G15E5rmm1haWY0lmXR2l4/edit?usp=sharing&#038;usp=embed_facebook" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">docs.google.com</div></div></div></div></a>





  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">GASで登録フォームを作る。</a><ol><li><a href="#toc2" tabindex="0">index.html</a></li><li><a href="#toc3" tabindex="0">js1.html</a></li><li><a href="#toc4" tabindex="0">css.html</a></li><li><a href="#toc5" tabindex="0">thankyou.html</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">GASで登録フォームを作る。</span></h2>



<p>doPost(e)でformから、下記内容を取り出すことができ、</p>



<p>{contentLength=116.0, parameter={usex=F, uaddress=愛知県蒲郡市, uname=山下太郎, umail=DAFAFA@KOA, uzip=123-4567}, parameters={uzip=[Ljava.lang.Object;@e0b929d, uaddress=[Ljava.lang.Object;@4defa65b, uname=[Ljava.lang.Object;@31f04075, umail=[Ljava.lang.Object;@7faa2595, usex=[Ljava.lang.Object;@2de7cf87}, contextPath=, queryString=, postData=FileUpload}</p>



<p>そこから情報を抜き出すためには、e.parameter.○○で</p>



<p>e.parameter.unam　⇒　山下太郎</p>



<p>が取り出せる形になります。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
function doGet() {
  let html = HtmlService.createTemplateFromFile('index').evaluate().getContent();
  return HtmlService.createHtmlOutput(html)
    .setSandboxMode(HtmlService.SandboxMode.IFRAME)
    .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

function doPost(e) {
  var sheet = SpreadsheetApp.openById(&quot;○○○○○○○○○○〇&quot;).getSheetByName(&quot;シート1&quot;);
  var array = &#x5B;e.parameter.uname, e.parameter.umail, e.parameter.usex, e.parameter.uaddress];
  sheet.appendRow(array);

  //  var html = HtmlService.createHtmlOutputFromFile(&quot;thankyou&quot;);
  let html = HtmlService.createTemplateFromFile('thankyou').evaluate().getContent();
  sheet.getRange(7,1).setvalue(html);
  return HtmlService.createHtmlOutput(html)
    .setSandboxMode(HtmlService.SandboxMode.IFRAME)
    .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);

}

//https://officeforest.org/wp/2018/11/28/google-apps-script%E3%81%A7get%E3%83%BBpost/
//https://nixeneko.hatenablog.com/entry/2021/03/12/070000

</pre></div>


<h3 class="wp-block-heading"><span id="toc2">index.html</span></h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&lt;!--/*%_skip_start_%*/--&gt;
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;ja&quot;&gt;

&lt;head&gt;
  &lt;meta http-equiv=&quot;content-Type&quot; content=&quot;text/html&quot; 　charset=&quot;utf-8&quot;&gt;
  &lt;title&gt;登録フォーム&lt;/title&gt;
  &lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
  &lt;?!= HtmlService.createHtmlOutputFromFile('css').getContent(); ?&gt;

&lt;/head&gt;

&lt;body&gt;
  &lt;div class=&quot;user&quot;&gt;
    &lt;header class=&quot;user__header&quot;&gt;
      &lt;img src=&quot;https://s3-us-west-2.amazonaws.com/s.cdpn.io/3219/logo.svg&quot; alt=&quot;&quot; /&gt;
      &lt;h1 class=&quot;user__title&quot;&gt;A lightweight and simple sign-up form&lt;/h1&gt;
    &lt;/header&gt;

    &lt;form class=&quot;form&quot; method=&quot;post&quot;
      action=&quot;https://script.google.com/macros/s/○○○○○○○○○○○○○○/exec&quot;&gt;
      &lt;div class=&quot;form__group&quot;&gt;
        &lt;!--      お名前を入力してください。（必須）&lt;br&gt; --&gt;
        &lt;input type=&quot;text&quot; name=&quot;uname&quot; id=&quot;uname&quot;  class=&quot;form__input&quot;  placeholder=&quot;Username&quot;&gt;
        &lt;span class=&quot;alert&quot;&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;!-- 性別を入力してください。（必須）&lt;br&gt; --&gt;
      &lt;input type=&quot;radio&quot; name=&quot;usex&quot; value=&quot;M&quot;&gt;男性
      &lt;input type=&quot;radio&quot; name=&quot;usex&quot; value=&quot;F&quot;&gt;女性
      &lt;span class=&quot;alert&quot;&gt;&lt;/span&gt;
      &lt;div class=&quot;form__group&quot;&gt;
        &lt;!-- メールアドレスを入力してください。（必須）&lt;br&gt;--&gt;
        &lt;input type=&quot;text&quot; name=&quot;umail&quot; size=&quot;50&quot; id=&quot;umail&quot; placeholder=&quot;Email&quot; class=&quot;form__input&quot;&gt;
        &lt;span class=&quot;alert&quot;&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;!-- 郵便番号を入力してください。（例：012-3456）&lt;br&gt; --&gt;
      &lt;div class=&quot;form__group&quot;&gt;
        &lt;input type=&quot;text&quot; name=&quot;uzip&quot; id=&quot;uzip&quot; placeholder=&quot;郵便番号(例:012-3456)&quot; class=&quot;form__input&quot;&gt;
        &lt;span class=&quot;alert&quot;&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;!-- 住所を入力してください。（100文字まで）&lt;br&gt; --&gt;
      &lt;div class=&quot;form__group&quot;&gt;
        &lt;textarea name=&quot;uaddress&quot; cols=&quot;50&quot; rows=&quot;3&quot; placeholder=&quot;住所&quot; class=&quot;form__input&quot;&gt;&lt;/textarea&gt;
        &lt;span class=&quot;alert&quot;&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;button  type=&quot;submit&quot; class=&quot;btn&quot;&gt;Register&lt;/button&gt;

    &lt;/form&gt;
  &lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;

&lt;!-- https://copypet.jp/692/--&gt;

<a rel="noopener" target="_blank" href="https://deshinon.com/2019/03/03/register-kopipe-css-oshare/" title="おしゃれシンプルデザインの新規登録フォーム！ コピペで差が付くデザインをCSSで - デシノン" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-right cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://deshinon.com/wp-content/uploads/2019/03/simplescreenrecorder20190313-6.gif" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">おしゃれシンプルデザインの新規登録フォーム！ コピペで差が付くデザインをCSSで - デシノン</div><div class="blogcard-snippet external-blogcard-snippet">ユーザーインターフェイスがよすぎる、おしゃれな新規登録フォームをまとめました！ プロ並のデザインなのに、ぜんぶコピペでできちゃう、、</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://deshinon.com/2019/03/03/register-kopipe-css-oshare/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">deshinon.com</div></div></div></div></a>
</pre></div>


<h3 class="wp-block-heading"><span id="toc3">js1.html</span></h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;


  $(function(){
	// フォームがサブミットされたときの処理
	$(&quot;form&quot;).submit(function(){
		// サブミットチェック用の変数を宣言
		var checkSubmit = true;

		// 名前の入力チェック
		if ($(&quot;#uname&quot;).val() == &quot;&quot;) {
			// 未入力時はerrorクラスを追加
			$(&quot;#uname&quot;).addClass(&quot;error&quot;);
			// メッセージを追加
			$(&quot;#uname+span&quot;).text(&quot;名前を入力してください。&quot;);
			// 未入力なのでサブミットさせない
			checkSubmit = false;
		} else {
			// 入力時はerrorクラスを削除
			$(&quot;#uname&quot;).removeClass(&quot;error&quot;);
			// メッセージを削除
			$(&quot;#uname+span&quot;).text(&quot;&quot;);
		}

		// 性別の入力チェック
		if ($(&quot;:radio:checked&quot;).length == 0) {
			// チェックされた要素がない（＝未入力）
			// errorクラスを追加
			$(&quot;:radio&quot;).addClass(&quot;error&quot;);
			// メッセージを追加
			$(&quot;:radio+span&quot;).text(&quot;性別を入力してください。&quot;);
			// 未入力なのでサブミットさせない
			checkSubmit = false;
		} else {
			// 入力時はerrorクラスを削除
			$(&quot;:radio&quot;).removeClass(&quot;error&quot;);
			// メッセージを削除
			$(&quot;:radio+span&quot;).text(&quot;&quot;);
		}

		// メールアドレスの入力チェック
		if ($(&quot;#umail&quot;).val() == &quot;&quot;) {
			// 未入力時はerrorクラスを追加
			$(&quot;#umail&quot;).addClass(&quot;error&quot;);
			// メッセージを追加
			$(&quot;#umail+span&quot;).text(&quot;メールアドレスを入力してください。&quot;);
			// 未入力なのでサブミットさせない
			checkSubmit = false;
		} else {
			// 入力時はerrorクラスを削除
			$(&quot;#umail&quot;).removeClass(&quot;error&quot;);
			// メッセージを削除
			$(&quot;#umail+span&quot;).text(&quot;&quot;);
		}

		// サブミットチェック用の変数を返す
		return checkSubmit;
	});

	// 名前が変更されたときの処理
	$(&quot;#uname&quot;).change(function(){
		// 名前の入力チェック
		if ($(&quot;#uname&quot;).val() == &quot;&quot;) {
			// 未入力時はerrorクラスを追加
			$(&quot;#uname&quot;).addClass(&quot;error&quot;);
			// メッセージを追加
			$(&quot;#uname+span&quot;).text(&quot;名前を入力してください。&quot;);
		} else {
			// 入力時はerrorクラスを削除
			$(&quot;#uname&quot;).removeClass(&quot;error&quot;);
			// メッセージを削除
			$(&quot;#uname+span&quot;).text(&quot;&quot;);
		}
	});

	// ラジオボタンがクリックされたときの処理
	$(&quot;:radio&quot;).click(function(){
		// 性別の入力チェック
		if ($(&quot;:radio:checked&quot;).length == 0) {
			// チェックされた要素がない（＝未入力）
			// errorクラスを追加
			$(&quot;:radio&quot;).addClass(&quot;error&quot;);
			// メッセージを追加
			$(&quot;:radio+span&quot;).text(&quot;性別を入力してください。&quot;);
		} else {
			// 入力時はerrorクラスを削除
			$(&quot;:radio&quot;).removeClass(&quot;error&quot;);
			// メッセージを削除
			$(&quot;:radio+span&quot;).text(&quot;&quot;);
		}
	});

	// メールアドレスが変更されたときの処理
	$(&quot;#umail&quot;).change(function(){
		// メールアドレスの書式チェック
		if ($(&quot;#umail&quot;).val().match(/^&#x5B;\w\.-]+\@&#x5B;\w\.-]+$/)) {
			// 書式が正しい
			$(&quot;#umail&quot;).removeClass(&quot;error&quot;);
			$(&quot;#umail+span&quot;).text(&quot;&quot;);
		} else {
			// 書式に誤りがある
			$(&quot;#umail&quot;).addClass(&quot;error&quot;);
			$(&quot;#umail+span&quot;).text(&quot;書式に誤りがあります。&quot;);
		}
	});

	// 郵便番号が変更されたときの処理
	$(&quot;#uzip&quot;).change(function(){
		// 郵便番号の書式チェック
		if ($(&quot;#uzip&quot;).val().match(/^\d{3}\-\d{4}$/)) {
			// 書式が正しい
			$(&quot;#uzip&quot;).removeClass(&quot;error&quot;);
			$(&quot;#uzip+span&quot;).text(&quot;&quot;);
		} else {
			// 書式に誤りがある
			$(&quot;#uzip&quot;).addClass(&quot;error&quot;);
			$(&quot;#uzip+span&quot;).text(&quot;書式に誤りがあります。&quot;);
		}
	});

	// 住所の入力中の処理
	$(&quot;textarea&quot;).keyup(function(){
		// 文字数を取得
		var inputLength = $(&quot;textarea&quot;).val().length;

		// 住所の文字数チェック
		if (inputLength &lt;= 100) {
			// 100文字以内
			$(&quot;textarea&quot;).removeClass(&quot;error&quot;);
			$(&quot;textarea+span&quot;).text(inputLength+&quot;/100&quot;);
		} else {
			// 100文字を超えた
			$(&quot;textarea&quot;).addClass(&quot;error&quot;);
			$(&quot;textarea+span&quot;).text(&quot;入力文字数が長すぎます。&quot;);
		}
	});
});

//cssの何か
const button = document.querySelector('.btn')
const form   = document.querySelector('.form')

button.addEventListener('click', function() {
   form.classList.add('form--no') 
});


&lt;/script&gt;
</pre></div>


<h3 class="wp-block-heading"><span id="toc4">css.html</span></h3>



<p>基本↓のサイトの内容からこのサイトに適応させております。<br>その他さまざまなCSSありますので、ぜひ参考に下さい。</p>





<a rel="noopener" target="_blank" href="https://deshinon.com/2019/03/03/register-kopipe-css-oshare/" title="おしゃれシンプルデザインの新規登録フォーム！ コピペで差が付くデザインをCSSで - デシノン" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-right cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://deshinon.com/wp-content/uploads/2019/03/simplescreenrecorder20190313-6.gif" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">おしゃれシンプルデザインの新規登録フォーム！ コピペで差が付くデザインをCSSで - デシノン</div><div class="blogcard-snippet external-blogcard-snippet">ユーザーインターフェイスがよすぎる、おしゃれな新規登録フォームをまとめました！ プロ並のデザインなのに、ぜんぶコピペでできちゃう、、</div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://deshinon.com/2019/03/03/register-kopipe-css-oshare/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">deshinon.com</div></div></div></div></a>



<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&lt;style&gt;
  //エラー用
  .error {
    background-color: #FFCCCC;
  }

  .alert {
    color: #FF0000;
    font-size: small;
  }

  //cssのもの

  $font-family: &quot;Roboto&quot;;
  $font-size: 14px;

  $color-primary: #ABA194;

  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  body {
    font-family: $font-family;
    font-size: $font-size;
    background-size: 200% 100% !important;
    animation: move 10s ease infinite;
    transform: translate3d(0, 0, 0);
    background: linear-gradient(45deg, #49D49D 10%, #A2C7E5 90%);
    height: 100vh
  }

  .user {
    width: 90%;
    max-width: 340px;
    margin: 10vh auto;
  }

  .user__header {
    text-align: center;
    opacity: 0;
    transform: translate3d(0, 500px, 0);
    animation: arrive 500ms ease-in-out 0.7s forwards;
  }

  .user__title {
    font-size: $font-size;
    margin-bottom: -10px;
    font-weight: 500;
    color: white;
  }

  .form {
    margin-top: 40px;
    border-radius: 6px;
    overflow: hidden;
    opacity: 0;
    transform: translate3d(0, 500px, 0);
    animation: arrive 500ms ease-in-out 0.9s forwards;
  }

  .form--no {
    animation: NO 1s ease-in-out;
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }

  .form__input {
    display: block;
    width: 100%;
    padding: 20px;
    font-family: $font-family;
    -webkit-appearance: none;
    border: 0;
    outline: 0;
    transition: 0.3s;

    &amp;:focus {
      background: darken(#fff, 3%);
    }
  }

  .btn {
    display: block;
    width: 100%;
    padding: 20px;
    font-family: $font-family;
    -webkit-appearance: none;
    outline: 0;
    border: 0;
    color: white;
    background: $color-primary;
    transition: 0.3s;

    &amp;:hover {
      background: darken($color-primary, 5%);
    }
  }

  @keyframes NO {

    from,
    to {
      -webkit-transform: translate3d(0, 0, 0);
      transform: translate3d(0, 0, 0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
      -webkit-transform: translate3d(-10px, 0, 0);
      transform: translate3d(-10px, 0, 0);
    }

    20%,
    40%,
    60%,
    80% {
      -webkit-transform: translate3d(10px, 0, 0);
      transform: translate3d(10px, 0, 0);
    }
  }

  @keyframes arrive {
    0% {
      opacity: 0;
      transform: translate3d(0, 50px, 0);
    }

    100% {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }

  @keyframes move {
    0% {
      background-position: 0 0
    }

    50% {
      background-position: 100% 0
    }

    100% {
      background-position: 0 0
    }
  }
&lt;/style&gt;
</pre></div>


<h3 class="wp-block-heading"><span id="toc5">thankyou.html</span></h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;ja&quot;&gt;

&lt;head&gt;
  &lt;meta http-equiv=&quot;content-Type&quot; content=&quot;text/html&quot; 　charset=&quot;utf-8&quot;&gt;
  &lt;title&gt;登録フォーム&lt;/title&gt;
  &lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
  &lt;?!= HtmlService.createHtmlOutputFromFile('css').getContent(); ?&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;div class=&quot;user&quot;&gt;
    &lt;header class=&quot;user__header&quot;&gt;
      &lt;img src=&quot;https://s3-us-west-2.amazonaws.com/s.cdpn.io/3219/logo.svg&quot; alt=&quot;&quot; /&gt;
      &lt;h1 class=&quot;user__title&quot;&gt;ありがとう&lt;/h1&gt;
    &lt;/header&gt;
  &lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;
</pre></div>]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/make-a-registration-form-with-gas/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【GAS_Webアプリ集】java-scriptを使う</title>
		<link>https://nujonoa.com/gas_web-application-collection/</link>
					<comments>https://nujonoa.com/gas_web-application-collection/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Mon, 04 Apr 2022 14:04:27 +0000</pubDate>
				<category><![CDATA[webアプリ]]></category>
		<category><![CDATA[Webアプリ]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[GAS]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=10486</guid>

					<description><![CDATA[目次 【GAS_Webアプリ集】java-scriptを動かす①javascriptでhtmlに文字を挿入②ボタンのクリック③文字の入力の反映④htmlの中身を確認、フィードバック⑤掛け算を行う⑥チェックボタン、ラジオボ [&#8230;]]]></description>
										<content:encoded><![CDATA[

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-4" checked><label class="toc-title" for="toc-checkbox-4">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">【GAS_Webアプリ集】java-scriptを動かす</a></li><li><a href="#toc2" tabindex="0">①javascriptでhtmlに文字を挿入</a></li><li><a href="#toc3" tabindex="0">②ボタンのクリック</a></li><li><a href="#toc4" tabindex="0">③文字の入力の反映</a></li><li><a href="#toc5" tabindex="0">④htmlの中身を確認、フィードバック</a></li><li><a href="#toc6" tabindex="0">⑤掛け算を行う</a></li><li><a href="#toc7" tabindex="0">⑥チェックボタン、ラジオボタンの使い方</a></li><li><a href="#toc8" tabindex="0">⑦チェックボタンでの分岐</a></li><li><a href="#toc9" tabindex="0">⑧送料無料などの分岐</a></li><li><a href="#toc10" tabindex="0">⑨時間での分岐</a></li><li><a href="#toc11" tabindex="0">⑩工事中・・・</a></li><li><a href="#toc12" tabindex="0">⑪マウスオーバーでコメント</a></li><li><a href="#toc13" tabindex="0">⑫テキストファイルの読み込み</a></li><li><a href="#toc14" tabindex="0">⑬写真の添付</a></li><li><a href="#toc15" tabindex="0">⑭文字列のソート</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading" id="gas-webアプリ集-java-scriptを動かす"><span id="toc1">【GAS_Webアプリ集】java-scriptを動かす</span></h2>



<h2 class="wp-block-heading" id="①javascriptでhtmlに文字を挿入"><span id="toc2">①javascriptでhtmlに文字を挿入</span></h2>



<p>javascriptでページに文字を挿入します。<br>↓の「がんばれ」はjavascriptにて挿入された文字になります。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbwGE6HsnR3wiJmtBZzcBxCIfTKb9M373Owur4f6SmpxKP72q1b5HgB1bC7w4RL7XkX_/exec" width="600" height="100"></iframe>



<h2 class="wp-block-heading" id="②ボタンのクリック"><span id="toc3">②ボタンのクリック</span></h2>



<p>ボタンをクリックすると、htmlを操作する動作をjavascriptにて作成します。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzHuz1w3iys49D4MVxitfq2SYgZJgMx2gFsJxlIPlKxirwk8QE_mG0vie9vaFZdZPeSdA/exec" width="600" height="100"></iframe>



<h2 class="wp-block-heading" id="③文字の入力の反映"><span id="toc4">③文字の入力の反映</span></h2>



<p>文字を入力、ボタンを押すことで、入力を行います。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbyRtrLkKL8aPXlxprlgFTg1LykZ8j6WxwrMLIpsFmCIxXZoX0SIPMoHo651h1M68YhV/exec" width="600" height="100"></iframe>



<h2 class="wp-block-heading" id="④htmlの中身を確認-フィードバック"><span id="toc5">④htmlの中身を確認、フィードバック</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbwnNAmIsQBf3rJ0upSkHkDroMCrmRdambeCFpIsGORADWia8h2Z42OBGn4C10spEkQ8/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="⑤掛け算を行う"><span id="toc6">⑤掛け算を行う</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzhUejYKa130J4UeK4dr4BggjP4sf33RGopNOWVpecn9U0x7oMWCeu8Ect8q9Q-XNS_-A/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="⑥チェックボタン-ラジオボタンの使い方"><span id="toc7">⑥チェックボタン、ラジオボタンの使い方</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzxMawSGHqDcREdFj2scaXnNcxbCEyRQcHs-DrEplzZsdytoCixiVUKwUUq9K-eajQ_/exec" width="300" height="200"></iframe>



<h2 class="wp-block-heading" id="⑦チェックボタンでの分岐"><span id="toc8">⑦チェックボタンでの分岐</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbyJse_kLgRfqgYyWirSaZdar4-1NlMTwtAU4lk0nOV0ODtWLrRjPwWAcIcTjFlGtVy9/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="⑧送料無料などの分岐"><span id="toc9">⑧送料無料などの分岐</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbx4MhM82BaIOzJ-4st8KHKv9BkYo2l728AKbrD0Wz7IIPGUzL8D4lWkNk1Pd4UDFzb7/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="⑨時間での分岐"><span id="toc10">⑨時間での分岐</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbwTzBrrJdZnGSO0M96E0FJBubx7wIDyNGGs3YwaDrTtPyVXs8uMCTo1QXLUzzXC7yZr/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="⑩工事中"><span id="toc11">⑩工事中・・・</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbwGE6HsnR3wiJmtBZzcBxCIfTKb9M373Owur4f6SmpxKP72q1b5HgB1bC7w4RL7XkX_/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="⑪マウスオーバーでコメント"><span id="toc12">⑪マウスオーバーでコメント</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbwGnoovlCeOgh5t5abiCDJ730SB2ZGzIXEe-wJGEXtJYyK7lwKDyuAicTaj01aGIZh5/exec" width="600" height="500"></iframe>



<h2 class="wp-block-heading" id="⑫テキストファイルの読み込み"><span id="toc13">⑫テキストファイルの読み込み</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbwlyuXV3KMrVjJZ4uOri_vjfOEDvyeG44iTk4FJOXBPY3kDcd1NoDb9sMa7Pd6Q3XY_/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="⑬写真の添付"><span id="toc14">⑬写真の添付</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzyzyBJKR7Z9FDdY4nvNR9Vg4vZ0iPNlTWdLoy2Xjjsv2kcDlUIBLOoLPAFERT9KZGO/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="⑭文字列のソート"><span id="toc15">⑭文字列のソート</span></h2>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbwqJBlDuWgGQSE1SvBafUYodxu6RZoRAqkYQQ4zjm16UWqFAvhQBN2fwidA-iK4tMRP/exec" width="600" height="500"></iframe>
]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/gas_web-application-collection/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【GAS_Webアプリ⑥】java-scriptでチェックボタンを使う</title>
		<link>https://nujonoa.com/gas_webapplication_6_checkbutton/</link>
					<comments>https://nujonoa.com/gas_webapplication_6_checkbutton/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Fri, 11 Feb 2022 14:18:46 +0000</pubDate>
				<category><![CDATA[webアプリ]]></category>
		<category><![CDATA[GAS]]></category>
		<category><![CDATA[Webアプリ]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=10450</guid>

					<description><![CDATA[目次 【GAS_Webアプリ⑥】java-scriptでチェックボタンを使うコードコード.jsindex.htmljs1.htmlCSS出力結果サンプル 【GAS_Webアプリ⑥】java-scriptでチェックボタンを [&#8230;]]]></description>
										<content:encoded><![CDATA[

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-6" checked><label class="toc-title" for="toc-checkbox-6">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">【GAS_Webアプリ⑥】java-scriptでチェックボタンを使う</a></li><li><a href="#toc2" tabindex="0">コード</a><ol><li><a href="#toc3" tabindex="0">コード.js</a></li><li><a href="#toc4" tabindex="0">index.html</a></li><li><a href="#toc5" tabindex="0">js1.html</a></li><li><a href="#toc6" tabindex="0">CSS</a></li><li><a href="#toc7" tabindex="0">出力結果</a></li></ol></li><li><a href="#toc8" tabindex="0">サンプル</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading" id="gas-webアプリ⑥-java-scriptでチェックボタンを使う"><span id="toc1">【GAS_Webアプリ⑥】java-scriptでチェックボタンを使う</span></h2>



<p>今回は、GASのwebアプリでcheckボタン、radioボタンを使っていきたいと思います。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzxMawSGHqDcREdFj2scaXnNcxbCEyRQcHs-DrEplzZsdytoCixiVUKwUUq9K-eajQ_/exec" width="300" height="200"></iframe>



<h2 class="wp-block-heading" id="コード"><span id="toc2">コード</span></h2>



<h3 class="wp-block-heading" id="コード-js"><span id="toc3">コード.js</span></h3>



<p>まずは、ウェブアプリを立ち上げるためのおまじないです。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
function doGet() {
let html = HtmlService.createTemplateFromFile('index').evaluate().getContent();
return HtmlService.createHtmlOutput(html)
  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
  .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
</pre></div>


<h3 class="wp-block-heading" id="index-html"><span id="toc4">index.html</span></h3>



<p>次は、htmlです。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;script
  src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;
&gt;&lt;/script&gt;
&lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
</pre></div>


<p>　で、jQueryを呼び出し、js1の読み込み、cssの読み込みを行っています。</p>



<p>今回は、チェックボタンと、ラジオボタンを設置し、連動するようにします。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!--/*%_skip_start_%*/--&gt;
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;ja&quot;&gt;
&lt;head&gt;
	&lt;meta charset=&quot;utf-8&quot;&gt;
	&lt;title&gt;Check radio&lt;/title&gt;
	&lt;script
	  src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;
	&gt;&lt;/script&gt;
    &lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
　  &lt;?!= HtmlService.createHtmlOutputFromFile('css').getContent(); ?&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!--/*%_skip_end_%*/--&gt;
&lt;div&gt;
	チェックボックスを連動させる
	&lt;input type=&quot;checkbox&quot; id=&quot;check1&quot;&gt;
	→
	&lt;input type=&quot;checkbox&quot; id=&quot;check2&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
	ラジオボタンを連動させる
	&lt;input type=&quot;radio&quot; name=&quot;radio1&quot; value=&quot;1&quot;&gt;
	&lt;input type=&quot;radio&quot; name=&quot;radio1&quot; value=&quot;2&quot;&gt;
	→
	&lt;input type=&quot;radio&quot; name=&quot;radio2&quot; value=&quot;1&quot;&gt;
	&lt;input type=&quot;radio&quot; name=&quot;radio2&quot; value=&quot;2&quot;&gt;
&lt;/div&gt;
&lt;!--/*%_skip_start_%*/--&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;!--/*%_skip_end_%*/--&gt;

</pre></div>


<h3 class="wp-block-heading" id="js1-html"><span id="toc5">js1.html</span></h3>



<p>javascriptは下記のとおりです。</p>



<p>チェックボタン、ラジオボタンの値を取得して、<br>結果を反映させます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html&gt;

&lt;script&gt;

//ここに記述↓↓↓

// DOMの準備後に実行する内容
$(function() {
	// 1つ目のチェックボックスを押した時の処理を設定
	$(&quot;#check1&quot;).click(function() {
		// チェックボックスの値を取得
		var check1 = $(&quot;#check1&quot;).prop(&quot;checked&quot;);
		console.log(check1);	// コンソールに出力

		// 取得した値をチェックボックスに設定
		$(&quot;#check2&quot;).prop(&quot;checked&quot;, check1);
	});

	// 1つ目のラジオボタンを押した時の処理を設定
	$(&quot;input&#x5B;name=radio1]&quot;).click(function() {
		// ラジオボタンの値を取得
		var radio1 = $(&quot;input&#x5B;name=radio1]:checked&quot;).val();
		console.log(radio1);	// コンソールに出力

		// 取得した値をラジオボタンに設定
		$(&quot;input&#x5B;name=radio2]&quot;).val(&#x5B;radio1]);
	});
});

//ここに記述↑↑↑

&lt;/script&gt;
</pre></div>


<h3 class="wp-block-heading" id="css"><span id="toc6">CSS</span></h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;style&gt;

div.viewarea {
	background: #ffa;
	border: solid 1px #aa6;
	width: 40em;
	font-size: 11pt;
	padding: 0.5em;
}

textarea {
	width: 40em;
	font-size: 11pt;
	padding: 0.5em;
}




&lt;/style&gt;
</pre></div>


<h3 class="wp-block-heading" id="出力結果"><span id="toc7">出力結果</span></h3>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzxMawSGHqDcREdFj2scaXnNcxbCEyRQcHs-DrEplzZsdytoCixiVUKwUUq9K-eajQ_/exec" width="300" height="200"></iframe>



<h2 class="wp-block-heading" id="サンプル"><span id="toc8">サンプル</span></h2>



<p>サンプルを置いておきますので、コピーしてお使いください。</p>



<div class="wp-block-cocoon-blocks-button-1 button-block"><a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1cwvKFXREjCqblMupBieW9RKYYXkilL93HDPqfb9Vv1k/copy" class="btn btn-l btn-circle btn-shine">サンプルをコピー<span class="fa fa-external-link external-icon anchor-icon"></span></a></div>



<p></p>



<p>「デプロイ」→「デプロイをテスト」→「URLをクリック」<br>で簡単にウェブアプリをテストすることが可能です。</p>



<figure class="wp-block-image size-large"><a rel="noopener" target="_blank" href="https://nujonoa.com/wp-content/uploads/2022/02/image.png"><img loading="lazy" decoding="async" width="900" height="514" src="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png" alt="" class="wp-image-10515" srcset="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png 900w, https://nujonoa.com/wp-content/uploads/2022/02/image-500x286.png 500w, https://nujonoa.com/wp-content/uploads/2022/02/image-300x171.png 300w, https://nujonoa.com/wp-content/uploads/2022/02/image-768x439.png 768w, https://nujonoa.com/wp-content/uploads/2022/02/image-120x68.png 120w, https://nujonoa.com/wp-content/uploads/2022/02/image-160x90.png 160w, https://nujonoa.com/wp-content/uploads/2022/02/image.png 1228w" sizes="(max-width: 900px) 100vw, 900px" /></a></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/gas_webapplication_6_checkbutton/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【GAS_Webアプリ③】java-scriptで文字を入力</title>
		<link>https://nujonoa.com/gas_webapplication_%ef%bc%93_inputtext/</link>
					<comments>https://nujonoa.com/gas_webapplication_%ef%bc%93_inputtext/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Fri, 11 Feb 2022 13:55:32 +0000</pubDate>
				<category><![CDATA[webアプリ]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=10439</guid>

					<description><![CDATA[目次 【GAS_Webアプリ③】java-scriptで文字を入力コードコード.jsindex.htmljs1.htmlCSS出力結果サンプル 【GAS_Webアプリ③】java-scriptで文字を入力 今回は、文字入 [&#8230;]]]></description>
										<content:encoded><![CDATA[

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-8" checked><label class="toc-title" for="toc-checkbox-8">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">【GAS_Webアプリ③】java-scriptで文字を入力</a></li><li><a href="#toc2" tabindex="0">コード</a><ol><li><a href="#toc3" tabindex="0">コード.js</a></li><li><a href="#toc4" tabindex="0">index.html</a></li><li><a href="#toc5" tabindex="0">js1.html</a></li><li><a href="#toc6" tabindex="0">CSS</a></li></ol></li><li><a href="#toc7" tabindex="0">出力結果</a></li><li><a href="#toc8" tabindex="0">サンプル</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading" id="gas-webアプリ③-java-scriptで文字を入力"><span id="toc1">【GAS_Webアプリ③】java-scriptで文字を入力</span></h2>



<p>今回は、文字入力を紹介していきます。</p>



<p>↓文字を入力して実行を押すと、入力内容が反映されることが分かります。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbyRtrLkKL8aPXlxprlgFTg1LykZ8j6WxwrMLIpsFmCIxXZoX0SIPMoHo651h1M68YhV/exec" width="600" height="100"></iframe>



<h2 class="wp-block-heading" id="コード"><span id="toc2">コード</span></h2>





<a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1HtU3cdK3bZtThwFcas7T9orcfk0G3WPb-S3Oxqm5B9I/edit?usp=sharing" title="【テスト②】jQueryを使ってみる" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-right cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://lh7-us.googleusercontent.com/docs/AHkbwyJ4ZF6VozNIRZX-GSM-Bm7E16uQ4HDNFuvIzhZEhN5boCg8l00svlEJyC07MbyWdvZ5-jho38mz8EVwQKHPXjIQAovbqdkByr6TjJ2P6uQud6Kx7Ks=w1200-h630-p" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">【テスト②】jQueryを使ってみる</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://docs.google.com/spreadsheets/d/1HtU3cdK3bZtThwFcas7T9orcfk0G3WPb-S3Oxqm5B9I/edit?usp=sharing&#038;usp=embed_facebook" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">docs.google.com</div></div></div></div></a>




<h3 class="wp-block-heading" id="コード-js"><span id="toc3">コード.js</span></h3>



<p>まずは、実行コードです。<br>ここはもうおまじないみたいなものなので、この通り入力してください。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
function doGet() {
let html = HtmlService.createTemplateFromFile('index').evaluate().getContent();
return HtmlService.createHtmlOutput(html)
  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
  .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
</pre></div>


<h3 class="wp-block-heading" id="index-html"><span id="toc4">index.html</span></h3>



<p>次は、htmlです。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;script
  src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;
&gt;&lt;/script&gt;
&lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
</pre></div>


<p>　で、jQueryを呼び出し、js1の読み込み、cssの読み込みを行っています。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
    &lt;input type=&quot;text&quot; id=&quot;userText&quot; value=&quot;入力してね！！&quot;&gt;
    &lt;input type=&quot;button&quot; id=&quot;execButton&quot; value=&quot;実行&quot;&gt;
</pre></div>


<p>ここで、テキストのインプットと、ボタンを作成。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&lt;div class=&quot;viewarea&quot; id=&quot;output&quot;&gt;&lt;/div&gt;
</pre></div>


<p>ここに結果を書き出すようにしています。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;ja&quot;&gt;
&lt;head&gt;
	&lt;meta charset=&quot;utf-8&quot;&gt;
	&lt;title&gt;Input to page&lt;/title&gt;
	&lt;script
	  src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;
	&gt;&lt;/script&gt;
    &lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
　  &lt;?!= HtmlService.createHtmlOutputFromFile('css').getContent(); ?&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div&gt;
		&lt;input type=&quot;text&quot; id=&quot;userText&quot; value=&quot;入力してね！！&quot;&gt;
		&lt;input type=&quot;button&quot; id=&quot;execButton&quot; value=&quot;実行&quot;&gt;
	&lt;/div&gt;
	&lt;div class=&quot;viewarea&quot; id=&quot;output&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

</pre></div>


<h3 class="wp-block-heading" id="js1-html"><span id="toc5">js1.html</span></h3>



<p>jsは下記のとおりです。</p>



<p>クリックしたら、入力欄の値を取得して、結果を表示させています。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html&gt;

&lt;script&gt;

//ここに記述↓↓↓

// DOMの準備後に実行する内容
$(function() {
	// ［実行］ボタンを押した時の処理を設定
	$(&quot;#execButton&quot;).click(function() {
		// 入力欄の値を取得
		var text = $(&quot;#userText&quot;).val();

		// 取得した値をdiv領域に表示
		$(&quot;#output&quot;).text(text);
	});
});

&lt;/script&gt;
</pre></div>


<h3 class="wp-block-heading" id="css"><span id="toc6">CSS</span></h3>



<p>CSSは下記の通りで、好きな色、好きな枠線、大きさに調整ください。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;style&gt;

div.viewarea {
	background: #f5f5f5;
	border: solid 1px #aa6;
	width: 50em;
	font-size: 12pt;
	padding: 0.5em;
}

textarea {
	width: 50em;
	font-size: 12pt;
	padding: 0.5em;
}

&lt;/style&gt;
</pre></div>


<h2 class="wp-block-heading" id="出力結果"><span id="toc7">出力結果</span></h2>



<p>冒頭でも示した通り、下記のような動きになります。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbyRtrLkKL8aPXlxprlgFTg1LykZ8j6WxwrMLIpsFmCIxXZoX0SIPMoHo651h1M68YhV/exec" width="600" height="100"></iframe>



<div class="wp-block-group is-layout-flow wp-block-group-is-layout-flow">
<h2 class="wp-block-heading" id="サンプル"><span id="toc8">サンプル</span></h2>



<p>サンプルを置いておきますので、コピーしてお使いください。</p>



<div class="wp-block-cocoon-blocks-button-1 button-block"><a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1HtU3cdK3bZtThwFcas7T9orcfk0G3WPb-S3Oxqm5B9I/copy" class="btn btn-l btn-circle btn-shine">サンプルをコピー<span class="fa fa-external-link external-icon anchor-icon"></span></a></div>



<p></p>



<p>「デプロイ」→「デプロイをテスト」→「URLをクリック」<br>で簡単にウェブアプリをテストすることが可能です。</p>



<figure class="wp-block-image size-large"><a rel="noopener" target="_blank" href="https://nujonoa.com/wp-content/uploads/2022/02/image.png"><img loading="lazy" decoding="async" width="900" height="514" src="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png" alt="" class="wp-image-10515" srcset="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png 900w, https://nujonoa.com/wp-content/uploads/2022/02/image-500x286.png 500w, https://nujonoa.com/wp-content/uploads/2022/02/image-300x171.png 300w, https://nujonoa.com/wp-content/uploads/2022/02/image-768x439.png 768w, https://nujonoa.com/wp-content/uploads/2022/02/image-120x68.png 120w, https://nujonoa.com/wp-content/uploads/2022/02/image-160x90.png 160w, https://nujonoa.com/wp-content/uploads/2022/02/image.png 1228w" sizes="(max-width: 900px) 100vw, 900px" /></a></figure>
</div>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/gas_webapplication_%ef%bc%93_inputtext/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【GAS_Webアプリ②】java-scriptでボタンをクリック</title>
		<link>https://nujonoa.com/gas_webapplication_2_button/</link>
					<comments>https://nujonoa.com/gas_webapplication_2_button/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Fri, 11 Feb 2022 13:46:35 +0000</pubDate>
				<category><![CDATA[webアプリ]]></category>
		<category><![CDATA[クリック]]></category>
		<category><![CDATA[GAS]]></category>
		<category><![CDATA[Webアプリ]]></category>
		<category><![CDATA[ボタン]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=10436</guid>

					<description><![CDATA[目次 【GAS_Webアプリ②】java-scriptでボタンをクリックコードコード.jsindex.htmljs1.html出力結果サンプル 【GAS_Webアプリ②】java-scriptでボタンをクリック 今回は、 [&#8230;]]]></description>
										<content:encoded><![CDATA[

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-10" checked><label class="toc-title" for="toc-checkbox-10">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">【GAS_Webアプリ②】java-scriptでボタンをクリック</a></li><li><a href="#toc2" tabindex="0">コード</a><ol><li><a href="#toc3" tabindex="0">コード.js</a></li><li><a href="#toc4" tabindex="0">index.html</a></li><li><a href="#toc5" tabindex="0">js1.html</a></li></ol></li><li><a href="#toc6" tabindex="0">出力結果</a></li><li><a href="#toc7" tabindex="0">サンプル</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading" id="gas-webアプリ②-java-scriptでボタンをクリック"><span id="toc1">【GAS_Webアプリ②】java-scriptでボタンをクリック</span></h2>



<p>今回は、ボタンをクリックすることで、動作するウェブアプリを作成していきます。</p>



<h2 class="wp-block-heading" id="コード"><span id="toc2">コード</span></h2>



<h3 class="wp-block-heading" id="コード-js"><span id="toc3">コード.js</span></h3>



<p>まずはいつものおまじないです。<br>webアプリを立ち上げる動作になります。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
function doGet() {
let html = HtmlService.createTemplateFromFile('index').evaluate().getContent();
return HtmlService.createHtmlOutput(html)
  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
  .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
</pre></div>


<h3 class="wp-block-heading" id="index-html"><span id="toc4">index.html</span></h3>



<p>次は、htmlになります。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
</pre></div>


<p>でjs1.htmlのjavascriptを読み込む場所を作成し、<br>・実行ボタン<br>と<br>・アウトプットの場所<br>を記したhtmlを作成します。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;ja&quot;&gt;
&lt;head&gt;
	&lt;meta charset=&quot;utf-8&quot;&gt;
	&lt;title&gt;clicks&lt;/title&gt;
    &lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;input type=&quot;button&quot; id=&quot;execButton&quot; value=&quot;実行&quot;&gt;
	&lt;div id=&quot;output&quot;&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></div>


<h3 class="wp-block-heading" id="js1-html"><span id="toc5">js1.html</span></h3>



<p>今回のjavascriptからは「jQuery」を使用していきます。<br>jQueryは簡単にいうと、より簡単にjavascriptをかけるようにするテンプレートです。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js&quot;&gt;&lt;/script&gt;
</pre></div>


<p>で呼び出すことで、それ以降は簡単にjsを使用することができます。</p>



<p>今回は、ボタンを押すと→アウトプットのところに「クリックされました」と表示される仕組みです。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html&gt;

&lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js&quot;&gt;&lt;/script&gt;

&lt;script&gt;

//ここに記述↓↓↓

// DOMの準備後に実行する内容
$(function() {
	// ［実行］ボタンを押した時の処理を設定
	$(&quot;#execButton&quot;).click(function() {
		$(&quot;#output&quot;).append(&quot;クリックされました&lt;br&gt;&quot;);
	});

});

//ここに記述↑↑↑

&lt;/script&gt;
</pre></div>


<h2 class="wp-block-heading" id="出力結果"><span id="toc6">出力結果</span></h2>



<p>出力結果は下記のとおりです。</p>



<p>実行ボタンをクリックすると、「クリックされました」と表示されることが分かります。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzHuz1w3iys49D4MVxitfq2SYgZJgMx2gFsJxlIPlKxirwk8QE_mG0vie9vaFZdZPeSdA/exec" width="600" height="100"></iframe>



<h2 class="wp-block-heading" id="サンプル"><span id="toc7">サンプル</span></h2>



<p>サンプルを置いておきますので、コピーしてお使いください。</p>



<div class="wp-block-cocoon-blocks-button-1 button-block"><a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1HtU3cdK3bZtThwFcas7T9orcfk0G3WPb-S3Oxqm5B9I/copy" class="btn btn-l btn-circle btn-shine">サンプルをコピー<span class="fa fa-external-link external-icon anchor-icon"></span></a></div>



<p></p>



<p>「デプロイ」→「デプロイをテスト」→「URLをクリック」<br>で簡単にウェブアプリをテストすることが可能です。</p>



<figure class="wp-block-image size-large"><a rel="noopener" target="_blank" href="https://nujonoa.com/wp-content/uploads/2022/02/image.png"><img loading="lazy" decoding="async" width="900" height="514" src="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png" alt="" class="wp-image-10515" srcset="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png 900w, https://nujonoa.com/wp-content/uploads/2022/02/image-500x286.png 500w, https://nujonoa.com/wp-content/uploads/2022/02/image-300x171.png 300w, https://nujonoa.com/wp-content/uploads/2022/02/image-768x439.png 768w, https://nujonoa.com/wp-content/uploads/2022/02/image-120x68.png 120w, https://nujonoa.com/wp-content/uploads/2022/02/image-160x90.png 160w, https://nujonoa.com/wp-content/uploads/2022/02/image.png 1228w" sizes="(max-width: 900px) 100vw, 900px" /></a></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/gas_webapplication_2_button/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【GAS_Webアプリ①】java-scriptを動かす</title>
		<link>https://nujonoa.com/gas_webapplication_1_howto/</link>
					<comments>https://nujonoa.com/gas_webapplication_1_howto/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Fri, 11 Feb 2022 13:34:30 +0000</pubDate>
				<category><![CDATA[webアプリ]]></category>
		<category><![CDATA[GAS]]></category>
		<category><![CDATA[Webアプリ]]></category>
		<category><![CDATA[テスト]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=10434</guid>

					<description><![CDATA[GASでウェブアプリを作成するために、やはりjavascriptを覚えていかないと、、、 ということで、今回から、java-scriptを勉強していきたいと思います！ 目次 【GAS_Webアプリ①】java-scrip [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>GASでウェブアプリを作成するために、やはりjavascriptを覚えていかないと、、、</p>



<p>ということで、今回から、java-scriptを勉強していきたいと思います！</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-12" checked><label class="toc-title" for="toc-checkbox-12">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">【GAS_Webアプリ①】java-scriptを動かす！</a></li><li><a href="#toc2" tabindex="0">コード</a><ol><li><a href="#toc3" tabindex="0">コード.js</a></li><li><a href="#toc4" tabindex="0">index.html</a></li><li><a href="#toc5" tabindex="0">js1.html</a></li></ol></li><li><a href="#toc6" tabindex="0">出力結果</a></li><li><a href="#toc7" tabindex="0">サンプル</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading" id="gas-webアプリ①-java-scriptを動かす"><span id="toc1">【GAS_Webアプリ①】java-scriptを動かす！</span></h2>



<p>今回は、まずは、javascriptを動かすことができるコードの書き方を確認していこうと思います。</p>



<h2 class="wp-block-heading" id="コード"><span id="toc2">コード</span></h2>



<h3 class="wp-block-heading" id="コード-js"><span id="toc3">コード.js</span></h3>



<p>まずは、jsからです。</p>



<p>jsはウェブサイトを動かすときと同様に、<br>doGet()を使用して動かします。</p>



<p>埋め込んだ際に「このサイトは…」という表示が出ないように、<br>少し変わった表示のさせ方をしていますが、<br>この通り打ち込んでください。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
function doGet() {
let html = HtmlService.createTemplateFromFile('index').evaluate().getContent();
return HtmlService.createHtmlOutput(html)
  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
  .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
</pre></div>


<h3 class="wp-block-heading" id="index-html"><span id="toc4">index.html</span></h3>



<p>次はhtmlのコードです。</p>



<p>ここで重要なのは、</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
</pre></div>


<p>この部分です。<br>これは、「js1.html」のコードをここに持ってきなさい！！</p>



<p>という指令を出しているコードになっており、<br>実際、ここにそのままjsを打ち込むのと同様の処理となっています。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;ja&quot;&gt;
&lt;head&gt;
	&lt;meta charset=&quot;utf-8&quot;&gt;
	&lt;title&gt;JavaScript out HTML&lt;/title&gt;
    &lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></div>


<h3 class="wp-block-heading" id="js1-html"><span id="toc5">js1.html</span></h3>



<p>jvascriptの文章です。<br>htmlで保存してください。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;script&gt;
	document.writeln(&quot;がんばれ&quot;);
&lt;/script&gt;
</pre></div>


<p>今回は単純に。「がんばれ」という文章を打ち込むだけのコードになっています。</p>



<p>これが、先ほどの</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
</pre></div>


<p>の部分に挿入され、「index.html」で、指示した項目が表示されることになります。</p>



<h2 class="wp-block-heading" id="出力結果"><span id="toc6">出力結果</span></h2>



<p>出力結果は下記のとおりです。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbwGE6HsnR3wiJmtBZzcBxCIfTKb9M373Owur4f6SmpxKP72q1b5HgB1bC7w4RL7XkX_/exec" width="600" height="100"></iframe>



<p>がんばれと打ち込まれたことが分かります。</p>



<div class="wp-block-group is-layout-flow wp-block-group-is-layout-flow">
<h2 class="wp-block-heading" id="サンプル"><span id="toc7">サンプル</span></h2>



<p>サンプルを置いておきますので、コピーしてお使いください。</p>



<div class="wp-block-cocoon-blocks-button-1 button-block"><a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1ky8GnnLcLnK22P0DXMOZOoz1H_PzNRKdJJZih7wV4nM/copy" class="btn btn-l btn-circle btn-shine">ボタン<span class="fa fa-external-link external-icon anchor-icon"></span></a></div>



<p></p>



<p>「デプロイ」→「デプロイをテスト」→「URLをクリック」<br>で簡単にウェブアプリをテストすることが可能です。</p>



<figure class="wp-block-image size-large"><a rel="noopener" target="_blank" href="https://nujonoa.com/wp-content/uploads/2022/02/image.png"><img loading="lazy" decoding="async" width="900" height="514" src="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png" alt="" class="wp-image-10515" srcset="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png 900w, https://nujonoa.com/wp-content/uploads/2022/02/image-500x286.png 500w, https://nujonoa.com/wp-content/uploads/2022/02/image-300x171.png 300w, https://nujonoa.com/wp-content/uploads/2022/02/image-768x439.png 768w, https://nujonoa.com/wp-content/uploads/2022/02/image-120x68.png 120w, https://nujonoa.com/wp-content/uploads/2022/02/image-160x90.png 160w, https://nujonoa.com/wp-content/uploads/2022/02/image.png 1228w" sizes="(max-width: 900px) 100vw, 900px" /></a></figure>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/gas_webapplication_1_howto/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【GAS_Webアプリ⑤】java-scriptでかけ算をする</title>
		<link>https://nujonoa.com/gas_webapplication_5_calculation/</link>
					<comments>https://nujonoa.com/gas_webapplication_5_calculation/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Thu, 27 Jan 2022 05:47:16 +0000</pubDate>
				<category><![CDATA[webアプリ]]></category>
		<category><![CDATA[GAS]]></category>
		<category><![CDATA[Webアプリ]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=10447</guid>

					<description><![CDATA[目次 【GAS_Webアプリ①】java-scriptを動かすコードコード.jsindex.htmljs1.htmlCSS出力結果サンプル 【GAS_Webアプリ①】java-scriptを動かす 今回は、GASのウェブ [&#8230;]]]></description>
										<content:encoded><![CDATA[

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-14" checked><label class="toc-title" for="toc-checkbox-14">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">【GAS_Webアプリ①】java-scriptを動かす</a></li><li><a href="#toc2" tabindex="0">コード</a><ol><li><a href="#toc3" tabindex="0">コード.js</a></li><li><a href="#toc4" tabindex="0">index.html</a></li><li><a href="#toc5" tabindex="0">js1.html</a></li><li><a href="#toc6" tabindex="0">CSS</a></li><li><a href="#toc7" tabindex="0">出力結果</a></li></ol></li><li><a href="#toc8" tabindex="0">サンプル</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading" id="gas-webアプリ①-java-scriptを動かす"><span id="toc1">【GAS_Webアプリ①】java-scriptを動かす</span></h2>



<p>今回は、GASのウェブアプリ上で、javascriptを用いて、かけ算をしていきたいと思います。</p>



<p>サンプルは下記のとおりです。</p>



<p>商品と、個数を選択し、計算ボタンを押すことで計算がかけられます。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzhUejYKa130J4UeK4dr4BggjP4sf33RGopNOWVpecn9U0x7oMWCeu8Ect8q9Q-XNS_-A/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="コード"><span id="toc2">コード</span></h2>



<h3 class="wp-block-heading" id="コード-js"><span id="toc3">コード.js</span></h3>



<p id="コード-js">まずは、webアプリを起動するためのおまじないです。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
function doGet() {
let html = HtmlService.createTemplateFromFile('index').evaluate().getContent();
return HtmlService.createHtmlOutput(html)
  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
  .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
</pre></div>


<h3 class="wp-block-heading" id="index-html"><span id="toc4">index.html</span></h3>



<p>次は、htmlです。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;script
  src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;
&gt;&lt;/script&gt;
&lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
</pre></div>


<p>で、jQueryを呼び出し、js1の読み込み、cssの読み込みを行っています。</p>



<p>ボディは、<br>・商品の選択項目、個数の選択と<br>・結果の表示欄<br>を作成しています。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!--/*%_skip_start_%*/--&gt;
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;ja&quot;&gt;
&lt;head&gt;
	&lt;meta charset=&quot;utf-8&quot;&gt;
	&lt;title&gt;Get list val&lt;/title&gt;
	&lt;script
	  src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;
	&gt;&lt;/script&gt;
    &lt;?!= HtmlService.createHtmlOutputFromFile('js1').getContent(); ?&gt;
　  &lt;?!= HtmlService.createHtmlOutputFromFile('css').getContent(); ?&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!--/*%_skip_end_%*/--&gt;
&lt;div&gt;
	商品
	&lt;select id=&quot;item&quot;&gt;
		&lt;option value=&quot;100&quot; selected&gt;鉛筆 (100円)&lt;/option&gt;
		&lt;option value=&quot;200&quot;&gt;シャーペン (200円)&lt;/option&gt;
		&lt;option value=&quot;500&quot;&gt;ノートセット (500円)&lt;/option&gt;
	&lt;/select&gt;
	個数
	&lt;select id=&quot;num&quot;&gt;
		&lt;option value=&quot;1&quot; selected&gt;1個&lt;/option&gt;
		&lt;option value=&quot;2&quot;&gt;2個&lt;/option&gt;
		&lt;option value=&quot;3&quot;&gt;3個&lt;/option&gt;
	&lt;/select&gt;
	&lt;input type=&quot;button&quot; id=&quot;calcButton&quot; value=&quot;計算&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;viewarea&quot;&gt;
	単価「&lt;span id=&quot;itemSel&quot;&gt;&lt;/span&gt;」円、
	個数「&lt;span id=&quot;numSel&quot;&gt;&lt;/span&gt;」個で、
	合計「&lt;span id=&quot;result&quot;&gt;&lt;/span&gt;」円。
&lt;/div&gt;
&lt;!--/*%_skip_start_%*/--&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;!--/*%_skip_end_%*/--&gt;

</pre></div>


<h3 class="wp-block-heading" id="js1-html"><span id="toc5">js1.html</span></h3>



<p>javascriptは下記の通り、</p>



<p>・リストの値を取得<br>・値を入れ込む<br>・かけ算をする<br>・切り捨て<br>・結果を表示</p>



<p>としております。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html&gt;

&lt;script&gt;

//ここに記述↓↓↓

// DOMの準備後に実行する内容
$(function() {
	// ［計算］ボタンを押した時の処理を設定
	$(&quot;#calcButton&quot;).click(function() {
		// リストの値を取得
		var itemValue = $(&quot;#item option:selected&quot;).val();
		var numValue = $(&quot;#num option:selected&quot;).val();

		// リストの値を表示
		$(&quot;#itemSel&quot;).text(itemValue);
		$(&quot;#numSel&quot;).text(numValue);

		// 計算（掛け算）を行う
		var result = itemValue * numValue;

		// 切り捨て
		result = Math.floor(result);

		// 計算結果を表示
		$(&quot;#result&quot;).text(result);
	});

	// 初回表示用にプログラムからクリック
	$(&quot;#calcButton&quot;).click();
});

//ここに記述↑↑↑

&lt;/script&gt;
</pre></div>


<h3 class="wp-block-heading" id="css"><span id="toc6">CSS</span></h3>



<p>cssは下記のとおりです。色などは自由に変更ください。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&lt;style&gt;

div.viewarea {
	background: #ffa;
	border: solid 1px #aa6;
	width: 40em;
	font-size: 11pt;
	padding: 0.5em;
}

textarea {
	width: 40em;
	font-size: 11pt;
	padding: 0.5em;
}
&lt;/style&gt;
</pre></div>


<h3 class="wp-block-heading" id="出力結果"><span id="toc7">出力結果</span></h3>



<p>出力結果は下記のとおりです。</p>



<iframe loading="lazy" src="https://script.google.com/macros/s/AKfycbzhUejYKa130J4UeK4dr4BggjP4sf33RGopNOWVpecn9U0x7oMWCeu8Ect8q9Q-XNS_-A/exec" width="600" height="200"></iframe>



<h2 class="wp-block-heading" id="サンプル"><span id="toc8">サンプル</span></h2>



<p>サンプルを置いておきますので、コピーしてお使いください。</p>



<div class="wp-block-cocoon-blocks-button-1 button-block"><a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1G8Qi5N5zoYf7rUX-GeSWaF45ZaMaiC_0fpGk1GjkM4I/copy" class="btn btn-l btn-circle btn-shine">サンプルをコピー<span class="fa fa-external-link external-icon anchor-icon"></span></a></div>



<p></p>



<p>「デプロイ」→「デプロイをテスト」→「URLをクリック」<br>で簡単にウェブアプリをテストすることが可能です。</p>



<figure class="wp-block-image size-large"><a rel="noopener" target="_blank" href="https://nujonoa.com/wp-content/uploads/2022/02/image.png"><img loading="lazy" decoding="async" width="900" height="514" src="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png" alt="" class="wp-image-10515" srcset="https://nujonoa.com/wp-content/uploads/2022/02/image-900x514.png 900w, https://nujonoa.com/wp-content/uploads/2022/02/image-500x286.png 500w, https://nujonoa.com/wp-content/uploads/2022/02/image-300x171.png 300w, https://nujonoa.com/wp-content/uploads/2022/02/image-768x439.png 768w, https://nujonoa.com/wp-content/uploads/2022/02/image-120x68.png 120w, https://nujonoa.com/wp-content/uploads/2022/02/image-160x90.png 160w, https://nujonoa.com/wp-content/uploads/2022/02/image.png 1228w" sizes="(max-width: 900px) 100vw, 900px" /></a></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/gas_webapplication_5_calculation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
