• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

348
Vistas
Submit Form Data to Google Spreadsheet in another tab (sheet)

I have a website here having two Forms. One under RESERVE VIP TABLE and another in the footer where it says JOIN OUR NEWSLETTER. I've used the following code to submit data from the FORM to Google Sheets. Question is that the first form is working fine but how can I submit the data from Newsletter section to Google Sheets in a separate Tab named "Subscribe"?

Newsletter HTML:

<form method="POST" name="google-sheet">
    <input type="text" name="subscribeEmail" placeholder="Your Email Address">
        <div class="gold-button small">
                    <button type="submit">Submit →</button>
                    <span class="bttn-border left virticle"></span>
                    <span class="bttn-border right virticle"></span>
                    <span class="bttn-border top horizontal"></span>
                    <span class="bttn-border bottom horizontal"></span>
       </div>
</form>

Script I'm using for Reservation Form:

<script>
        const scriptURL = 'https://script.google.com/macros/s/AKfycbzJA2cZGROFNCwLuPnJjECW21zXMZs8nT4Xo0Nzjy5ETlOVQ3gHgyjE3wzzmHky_0I_/exec'
        const form = document.forms['google-sheet']
      
        form.addEventListener('submit', e => {
          e.preventDefault()
          fetch(scriptURL, { method: 'POST', body: new FormData(form)})
            .catch(error => console.error('Error!', error.message))
        })
</script>
almost 3 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If it were me, I'd have to tackle it like this:

HTML:

<form action="https://script.google.com/macros/s/[SCRIPT ID]/exec" method="post">
  <input type="text" name="subscribeEmail" placeholder="Your Email Address">
  <div class="gold-button small">
    <button type="submit">Submit →</button>
    <span class="bttn-border left virticle"></span>
    <span class="bttn-border right virticle"></span>
    <span class="bttn-border top horizontal"></span>
    <span class="bttn-border bottom horizontal"></span>
  </div>
</form>

Apps Script:

function doPost(e) {
  var ss = SpreadsheetApp.openById("SHEET ID");
  var sheet = ss.getSheetByName("Subscribe");
  // or use getRange().setValue() if something specific
  sheet.appendRow([e.parameter.subscribeEmail])
}

Reference:

  • Run Google App Script from web page
almost 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda