Title1
Title2
Title3
Login
Link
Search
教學頻道
GAS+購物車開發
Google表單+電商購物車
中信金融管理學院
點二下資訊社
新化社區大學
GAS專案
GAS+購物車開發
Google表單實戰電商購物車
GAS+LineBot開發
外帶內用管理
購物車管理
線上打卡系統管理
萬用表單5
LineBot 線上書籍
PHP專案
網站程式設計-PHP(10502)
網站程式設計-PHP
PHP SMARTY 樣板引擎
SMARTY樣板
課程教材
雲端工具入門
行動應用企劃人員養成班
萬用表單5
GAS+LineBot開發
研習
萬用表單5
鐵人賽-Google Apps Script整合運用
GAS+LineBot開發
樂齡3C學習不斷電
臺東專科學校
GAS 開發 LineBot 自動接單系統
德鍵
112行動應用企劃人員養成班
111網頁前端設計工程師培訓班
110網頁前端設計工程師培訓班
網頁前端設計工程師培訓班
old
網頁前端設計與開發運用培訓班
Javascript & JQUERY
免費釋出專案
萬用表單
自動資料查詢
台南社大
113-01-雲端工具入門
112-02-AI自動管理
112-01-用QRCODE打造自動化環境
110-01-用雲端打造自動化環境
用雲端打造自動化環境
Google雲端智慧王
讓雲端工具提昇工作效率
Google 速學工作術
台南市總圖
教你如何使用LINE Bot機器人增加工作效率
Google雲端工具基礎應用
Google雲端工具進階應用
工作自動化與行銷(台南社大)
全部教材
台南市人力發展中心
Google工具應用實務班
企業課程
鐳達實業有限公司
GAS研習-20200726
中正大學-GAS研習
將軍圖書館
Google雲端工具基礎應用
Google雲端工具進階應用
南方創客
GitHub 衍伸應用
Google 應用工作術
永康社大
用雲端打造自動化環境(110-春季班)
用雲端打造自動化環境
南關社大
電腦、手機生活應用
遠端桌面
公司業務
傳送檔案
adwcleaner
W10 更新
客戶網站
最近完工
深雋設計有限公司
新化社大校務系統
靚品科技有限公司
5C Precision Co., Ltd.
BALANCE 1
RWD網站
東北關廟麵
曼馱有限公司
永宸昕有限公司
昌美實業社
形象網站
勇信機械有限公司
GAS專案
聯絡我們&案件委託
所有書籍
「雲端工具入門」目錄
MarkDown
11-2 Line通知
1. ChatGPT聊天機器人
2. 使用Google Site 建立網站
2-1 自訂網域
2-2 Workspace協作平台-自訂網域
2-3 網頁設計素材
3. 使用Google Forms 建立互動式表單
3-1 門診叫號管理
3-2 自動替換網址 表單
4. 使用Google Spreadsheet收集資料
4-1 聯絡我們 功能加強
5. 期中整合運用
6. 使用Google 日曆
6-1 LineNotify 通知
6-2 設定Google日曆函式
6-3 宣告 設定Google日曆函式 所需變數
6-4 完成結果
6-5 嵌入網站
6-6 共用日曆
7. 使用Google 雲端硬碟
8. 使用Google 地圖
9. 使用Google Apps Script
10. 整合運用-在網站建立聯絡我們-Line通知
10-1 申請Line Notify 權杖
10-2 聯絡我們
10-3 門診叫號
10-4 自動替換網址
11. 整合運用 - 公司訂便當」系統
11-1 訂便當 Google表單
11-2 Line通知
11-3 試算表增加欄位
11-4 顯示工作表資料
11-5 部署為網站應用程式
12. 整合運用 - 用Google表單建立購物車
12-1 Google表單購物車
12-1-1 Google表單購物車 功能加強
12-1-2 取得標題列資料
12-1-3 寫資料至儲存格
12-1-4 詢問 Chat GPT
12-1-5 分析 onFormSubmit(e)
12-1-6 結果
12-1-7 完成 Google表單-購物車
13. 專題:Google表單接收 POST、GET
13-1 網址自動轉換
11-4 顯示工作表資料
雲端工具入門 ====== ### 增加欄位 1.
在「餐點」右邊增加「單價」
2.
糖、冰 \[冰\] 右邊增加「小計」
### 印出傳入變數e 1.
console.log(e); => 去執行填表單並送出=>在編輯器的執行項目觀看變數
```javascript Logging output too large. Truncating output. { toString: [Function], authMode: { toString: [Function: toString], name: [Function: toString], toJSON: [Function: toString], ordinal: [Function: ordinal], compareTo: [Function: compareTo], NONE: { toString: [Function: toString], name: [Function: toString], toJSON: [Function: toString], ordinal: [Function: ordinal], compareTo: [Function: compareTo], NONE: [Circular], CUSTOM_FUNCTION: [Object], LIMITED: [Object], FULL: [Circular] }, CUSTOM_FUNCTION: { toString: [Function: toString], name: [Function: toString], toJSON: [Function: toString], ordinal: [Function: ordinal], compareTo: [Function: compareTo], NONE: [Object], CUSTOM_FUNCTION: [Circular], LIMITED: [Object], FULL: [Circular] }, LIMITED: { toString: [Function: toString], name: [Function: toString], toJSON: [Function: toString], ordinal: [Function: ordinal], compareTo: [Function: compareTo], NONE: [Object], CUSTOM_FUNCTION: [Object], LIMITED: [Circular], FULL: [Circular] }, FULL: [Circular] }, namedValues: { '時間戳記': [ '2024/5/23 下午 5:44:03' ], '糖、冰 [糖]': [ '5分' ], '糖、冰 [冰]': [ '5分' ], '是否升級為套餐?(附飲料甜點,加 25 元)': [ '是' ], '姓名': [ '123' ], '餐點': [ '照燒雞腿飯 $130元' ] }, range: { toString: [Function], setComment: [Function], getComment: [Function], getFilter: [Function], setNumberFormat: [Function], getNumberFormat: [Function], clear: [Function], getValue: [Function], isBlank: [Function], merge: [Function], check: [Function], setValue: [Function], offset: [Function], sort: [Function], copyTo: [Function], setValues: [Function], trimWhitespace: [Function], createDataSourceTable: [Function], setTextRotation: [Function], getA1Notation: [Function], setFontFamilies: [Function], setFontLine: [Function], setFontLines: [Function], setFontSizes: [Function], setFontStyle: [Function], setFontStyles: [Function], setFontWeight: [Function], setFontWeights: [Function], setHorizontalAlignments: [Function], setNumberFormats: [Function], setVerticalAlignments: [Function], copyValuesToRange: [Function], copyFormatToRange: [Function], getFontColor: [Function], getFontColorObject: [Function], getFontColors: [Function], getFontColorObjects: [Function], getFontLine: [Function], getFontLines: [Function], getFontSizes: [Function], getFontStyle: [Function], getFontStyles: [Function], getFontWeights: [Function], getHorizontalAlignment: [Function], getHorizontalAlignments: [Function], getVerticalAlignments: [Function], isStartColumnBounded: [Function], isStartRowBounded: [Function], isEndColumnBounded: [Function], isEndRowBounded: [Function], autoFillToNeighbor: [Function], setShowHyperlink: [Function], getTextRotation: [Function], getTextRotations: [Function], setTextRotations: [Function], setVerticalText: [Function], setTextDirections: [Function], getTextDirections: [Function], splitTextToColumns: [Function], applyRowBanding: [Function], applyColumnBanding: [Function], setWrapStrategy: [Function], setWrapStrategies: [Function], getWrapStrategy: [Function], getWrapStrategies: [Function], createPivotTable: [Function], createDataSourcePivotTable: [Function], shiftRowGroupDepth: [Function], shiftColumnGroupDepth: [Function], expandGroups: [Function], collapseGroups: [Function], getRichTextValue: [Function], getRichTextValues: [Function], setRichTextValue: [Function], setRichTextValues: [Function], getTextStyles: [Function], setTextStyles: [Function], insertCheckboxes: [Function], removeCheckboxes: [Function], activateAsCurrentCell: [Function], deleteCells: [Function], getEndColumn: [Function], getNextDataCell: [Function], getDataRegion: [Function], getFormulaR1C1: [Function], getFormulasR1C1: [Function], getDataSourceFormula: [Function], getNumberFormats: [Function], getBackgroundColors: [Function], insertCells: [Function], setFormulas: [Function], setFormulaR1C1: [Function], setFormulasR1C1: [Function], setBackgroundColors: [Function], getDisplayValue: [Function], getDisplayValues: [Function], mergeAcross: [Function], mergeVertically: [Function], isPartOfMerge: [Function], setBackgroundObject: [Function], setBackgrounds: [Function], getBackgroundObject: [Function], getBackgrounds: [Function], getBackgroundObjects: [Function], setBackgroundRGB: [Function], setComments: [Function], setFontColor: [Function], setFontColorObject: [Function], setFontColors: [Function], setBackground: [Function], clearComment: [Function], getNumRows: [Function], getFontFamilies: [Function], getFormulas: [Function], activate: [Function], uncheck: [Function], getEndRow: [Function], breakApart: [Function], getBorders: [Function], getSheet: [Function], setBorder: [Function], setWrap: [Function], setWraps: [Function], getGridId: [Function], getWrap: [Function], getWraps: [Function], randomize: [Function], autoFill: [Function], isChecked: [Function], getBorder: [Function], getTextDirection: [Function], setTextDirection: [Function], getRowIndex: [Function], getColumnIndex: [Function], getTextStyle: [Function], getFontWeight: [Function], getBackground: [Function], getNumColumns: [Function], getBackgroundColor: [Function], setBackgroundColor: [Function], getVerticalAlignment: [Function], getFontFamily: [Function], setFontFamily: [Function], setTextStyle: [Function], getComments: [Function], getCell: [Function], getRow: [Function], getWidth: [Function], clearFormat: [Function], moveTo: [Function], clearContent: [Function], createFilter: [Function], protect: [Function], getMergedRanges: [Function], setBackgroundObjects: [Function], setFontColorObjects: [Function], getDataValidation: [Function], getDataValidations: [Function], setDataValidation: [Function], setDataValidations: [Function], clearDataValidations: [Function], setFontSize: [Function], getHeight: [Function], getLastRow: [Function], getFontSize: [Function], getDataSourceUrl: [Function], getDataTable: [Function], getBandings: [Function], createTextFinder: [Function], addDeveloperMetadata: [Function], getDeveloperMetadata: [Function], getLastColumn: [Function], getDataSourcePivotTables: [Function], getDataSourceTables: [Function], getDataSourceFormulas: [Function], createDeveloperMetadataFinder: [Function], setHorizontalAlignment: [Function], setVerticalAlignment: [Function], canEdit: [Function], setNotes: [Function], getNotes: [Function], getFormula: [Function], setFormula: [Function], getColumn: [Function], getNote: [Function], clearNote: [Function], setNote: [Function], removeDuplicates: [Function], getValues: [Function], columnEnd: 7, columnStart: 1, rowEnd: 3, rowStart: 3 }, source: { toString: [Function], isReadable: [Function], isWritable: [Function], getName: [Function], getKey: [Function], setName: [Function], getId: [Function], copy: [Function], getOwner: [Function], rename: [Function], getUrl: [Function], getSheets: [Function], addMenu: [Function], removeMenu: [Function], msgBox: [Function], inputBox: [Function], toast: [Functi ``` 2.
請看到「namedValues」
3.
我們也要利用 head
4.
console.log(e.namedValues); console.log(head);
5. ```javascript 2024年5月23日 下午5:49:47 偵錯 { '餐點': [ '日式豬排飯 $120 元' ], '時間戳記': [ '2024/5/23 下午 5:49:45' ], '姓名': [ 'qqq' ], '糖、冰 [糖]': [ '7分' ], '糖、冰 [冰]': [ '7分' ], '是否升級為套餐?(附飲料甜點,加 25 元)': [ '是' ] } 2024年5月23日 下午5:49:47 偵錯 [ '時間戳記', '姓名', '餐點', '單價', '是否升級為套餐?(附飲料甜點,加 25 元)', '糖、冰 [糖]', '糖、冰 [冰]', '小計' ] ``` ### 增加程式碼:在 let head 與 let row 之間 ```javascript //------------------------------------- 傳入的值 let namedValues = e.namedValues; //------------------------------------- 欄號 let priceIndex = head.indexOf('單價') + 1; //單價欄號 let subtotalIndex = head.indexOf('小計') + 1; //小計欄號 //------------------------------------- 取得餐點、是否升級 let meal = namedValues['餐點'][0]; // 餐點 let upgrade = namedValues['是否升級為套餐?(附飲料甜點,加 25 元)'][0]; // 是否升級為套餐? //-------------------------------------在這裡進行單價和小計的計算(根據您的需求) let price = extractNumberFromString(meal); // 如果升級為套餐,則加 25 元 let subtotal = (upgrade === '是') ? price + 25 : price; //------------------------------------- 寫入單價和小計 ws.getRange(rowIndex, priceIndex).setValue(price); // 單價 ws.getRange(rowIndex, subtotalIndex).setValue(subtotal); // 小計 ``` ### 將餐點的單價分離函式 ```javascript function extractNumberFromString(str) { // 使用正则表达式匹配字符串中的数字 var matches = str.match(/\d+/); if (matches && matches.length > 0) { var numberValue = parseInt(matches[0]); // 将匹配的数字字符串转换为整数 return numberValue; } else { // Logger.log('未找到数字'); return 0; } } ```