Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chiraag-kakar/contactme
A simple contact form built using HTML , CSS , Javascript & G-Script that uses google sheets as database.
https://github.com/chiraag-kakar/contactme
css database google-sheets gscript html javascript
Last synced: 5 days ago
JSON representation
A simple contact form built using HTML , CSS , Javascript & G-Script that uses google sheets as database.
- Host: GitHub
- URL: https://github.com/chiraag-kakar/contactme
- Owner: chiraag-kakar
- Created: 2020-09-28T08:36:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-09T03:37:06.000Z (over 4 years ago)
- Last Synced: 2023-08-07T19:27:58.574Z (over 1 year ago)
- Topics: css, database, google-sheets, gscript, html, javascript
- Language: HTML
- Homepage: https://chiraag-kakar.github.io/contactme
- Size: 9.77 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/chiraag-kakar/contactme/pulls)
πHit that β button to show some β€οΈ
# Contact Me
A simple contact form built using HTML , CSS , Javascript & G-Script. The collected data is saved in google sheets in real-time.[View Form](https://chiraag-kakar.github.io/contactme/) | [View Database](https://chiraag-kakar.github.io/viewcontacts/)
## The Google script associated with the Google sheet is :
**Note** : Make sure the G-Script Project name is same as that of the Google Sheet Document. `sheetName` is the name of one sheet and not the entire document.```gs
var sheetName = 'Sheet1'
var scriptProp = PropertiesService.getScriptProperties()function intialSetup () {
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet()
scriptProp.setProperty('key', activeSpreadsheet.getId())
}function doPost (e) {
var lock = LockService.getScriptLock()
lock.tryLock(10000)try {
var doc = SpreadsheetApp.openById(scriptProp.getProperty('key'))
var sheet = doc.getSheetByName(sheetName)var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]
var nextRow = sheet.getLastRow() + 1var newRow = headers.map(function(header) {
return header === 'timestamp' ? new Date() : e.parameter[header]
})sheet.getRange(nextRow, 1, 1, newRow.length).setValues([newRow])
return ContentService
.createTextOutput(JSON.stringify({ 'result': 'success', 'row': nextRow }))
.setMimeType(ContentService.MimeType.JSON)
}catch (e) {
return ContentService
.createTextOutput(JSON.stringify({ 'result': 'error', 'error': e }))
.setMimeType(ContentService.MimeType.JSON)
}finally {
lock.releaseLock()
}
}
```