第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 Google App 腳本中指定 HTML/Javascript 表單

在 Google App 腳本中指定 HTML/Javascript 表單

炎炎設(shè)計 2024-01-22 15:54:12
我有兩個 HTML 表單。兩者都執(zhí)行類似的任務(wù),您填寫它們,然后它們發(fā)送電子郵件。填寫表單后單擊提交按鈕后,我調(diào)用 Google 應(yīng)用程序腳本來構(gòu)建電子郵件并發(fā)送。我的問題是,盡管我的設(shè)置彼此隔離,但兩個提交按鈕現(xiàn)在都發(fā)送相同的電子郵件。我想問題是我如何告訴GAS指定哪種形式?這是我第一次做這些,現(xiàn)在我很困惑。以下是 Form A html 的結(jié)尾:<input class="w3-button w3-block w3-section w3-blue w3-ripple w3-padding" type="button" value="Submit project request" onclick="google.script.run.sendEmail(this.parentNode)" />我的 Form A 應(yīng)用程序腳本是:// listen for an object sent from the HTML formfunction projectRequest(formObj) {Form A 在其 html 中的名稱為:<form name="projectrequest" action="/action_page.php" class="w3-container w3-card-4 w3-light-grey w3-text-blue w3-margin">所以我認(rèn)為我的問題是因為表單 B 類似并且我正在調(diào)用 formObj?表單 B 是我原來的工具,填寫后工作正常,但按表單 A 上的相同提交按鈕會嘗試運(yùn)行表單 B 的應(yīng)用程序腳本電子郵件代碼。表格 B html 結(jié)尾:<input class="w3-button w3-block w3-section w3-blue w3-ripple w3-padding" type="button" value="Send Email" onclick="google.script.run.sendEmail(this.parentNode)" />Form B 應(yīng)用程序腳本為:function sendEmail(formObj) {html 中的 Form B 名稱為:<form name="furtherhelp" action="/action_page.php" class="w3-container w3-card-4 w3-light-grey w3-text-blue w3-margin">有人可以提供建議嗎,我真的很困惑,希望這只是小事。謝謝。
查看完整描述

1 回答

?
月關(guān)寶盒

TA貢獻(xiàn)1772條經(jīng)驗 獲得超5個贊

我使用隱藏元素來區(qū)分它們。


ah1.html:


<!DOCTYPE html>

<html>

  <head>

    <base target="_top">

  <script>

    function processForm(form) {

      console.log(form);

      google.script.run

      .withSuccessHandler(function(obj){

        console.log(obj);

        document.getElementById("eml" + obj.number).value="";

        document.getElementById("sub" + obj.number).value="";

        document.getElementById("msg" + obj.number).value="";

        //document.getElementById("ret" + obj.number).innerHTML=obj.msg;

      })

      .processForm(form);

    }

    console.log('My Code');

  </script>

  </head>

  <body>

   <form name="form1">

     <input type="text" name="email" id="eml1" placeholder="Enter Email" />

     <input type="text" name='subject' id="sub1" placeholder="Enter Subject" />

     <textarea rows="4" name="message" cols="30" id="msg1" placeholder="Enter Message"></textarea>

     <input type="hidden" name="number" value="1" />

     <input type="button" value="Submit" onClick="processForm(this.parentNode);" />

   </form>

   <div id="ret1"></div>

   <form name="form2">

     <input type="text" name="email" id="eml2" placeholder="Enter Email" />

     <input type="text" name="subject" id="sub2" placeholder="Enter Subject"/>

     <textarea rows="4" name="message" cols="30" id="msg2" placeholder="Enter Message"></textarea>

     <input type="hidden" name="number" value="2" />

     <input type="button" value="Submit" onClick="processForm(this.parentNode);" />

   </form>

    <div id="ret2"></div>

  </body>

  <input type="button" value="close" onClick="google.script.host.close();" />

</html>

code.gs:


function launchSideBar() {

  SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile("ah1"));

}


function processForm(obj) {

  console.log(obj);

  const ss=SpreadsheetApp.getActive();

  const sh=ss.getSheetByName('email');

  sh.appendRow([obj.email,obj.subject,obj.message]);

  return {number:obj.number,msg:"Email Sent"}

}


查看完整回答
反對 回復(fù) 2024-01-22
  • 1 回答
  • 0 關(guān)注
  • 130 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號