Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .container
  h1.text-center
    | 【GAS】 スプレッドシートと連携したAjaxフォーム
  hr
  form.form-horizontal action='https://script.google.com/macros/s/AKfycbxI3xhvF7LPOwJJInnredfxkDfkNyDTvkqUSRIysNye3X2s8R4/exec'
    input type='hidden' name='SPREADSHEET_ID' value='179G_PAUfFupy5T1rN1WKadgdSnCzpYL8JU7FdEGd54k'
    input type='hidden' name='SHEET_NAME' value='フォームデータ'
    .form-group
      label.col-md-2.control-label メールアドレス
      .col-md-10
        input.form-control name='メールアドレス' placeholder='test@test.com' type='email'
        p.help-block
          | メールアドレスを入力すると、そのアドレス宛に自動返信メールを送信します。
          br
          | メールアドレスはスプレッドシートに登録されないので、安心してお試し下さい。自分のGmail(lab.snowsunny)に送信履歴が残りますが、その情報を何かに使用する事は有りません。
          br
          | どうしても不安なら
          a href='https://one-time.email' One-Time.Email
          | を使うのがおすすめです!HTMLメールとテキストメールの両方を同時に確認する事が出来ます。
    .form-group
      label.col-md-2.control-label Qiitaのユーザー名
      .col-md-10
        input.form-control name='Qiitaのユーザー名' placeholder='良ければQiitaのユーザー名を教えて下さーい'
    .form-group
      label.col-md-2.control-label 一言コメント
      .col-md-10
        input.form-control name='一言コメント' placeholder='適当でOK。何かコメントを貰えるだけで喜びます!(`・ω・´)b' required='required'
    .form-group
      .col-md-offset-2.col-md-10
        button.btn.btn-primary type='submit' 送信
  hr
  h3.text-center Qiitaの投稿記事
  p.text-center このサンプルは下記リンクの投稿用の物です。
  .text-center
    a href='http://qiita.com/snowsunny/items/56a85c63598dcfb1b06e'
      | 【短いコードで色々出来る】Google Apps Scriptでスプレッドシートと連携した無料Ajaxフォームの作り方※サンプル付き【自動返信メールもあるよ】
              
            
!

CSS

              
                form.form-horizontal
  .label.label-danger
    border-radius: 4px
    border-bottom-left-radius: 0px
    border-bottom-right-radius: 0px
  input[required]
    border-top-left-radius: 0px
    
              
            
!

JS

              
                $ ->
  required_tag = '<span class="label label-danger">必須</span>'
  requires = $('form [required]').each (i, elm)->
    $(elm).before required_tag

  $('form').validate
    debug: true
    submitHandler: (e)->
      form = $ e
      btn_submit = form.find('button[type=submit]')
      $.ajax
        url: form.attr 'action'
        dataType: 'jsonp'
        data: form.serialize()

        beforeSend: ->
          btn_submit.attr 'disabled', true
        complete: ->
          btn_submit.attr 'disabled', false

        success: (response)->
          console.log response
          # 成功したらサンクスページとかに飛ばす処理の例↓
          # window.location.href = 'https://codepen.io/snowsunny'
        error: (response)->
          console.log response

              
            
!
999px

Console