Online data entry forms are a powerful tool that you can use to collect many types of data more easily and accurately. Google Sheets is the most powerful cloud-based spreadsheet application that you can use absolutely free. Google is also offering another free tool named Google Apps Script (GAS) to increase the power of your favorite Google apps. In this post, I will explain to you how you can create a free online form (or Web App) that can perform Create, Read, Update and Delete (CRUD) Operations on Google Sheets using Google Apps Script and Google Sheets API v4.
Why I Should Create online Data Entry Forms
You can improve the productivity of your work by creating an HTML form to submit data to Google Sheets than directly typing data on the Sheet.
- Easy to share the form and ask all your staff or team members to submit data to the same Sheet and at the same time.
- You need not give Google Sheet edit access to your team, so your data is secure
- Reduce human errors
- Increase the reliability of your data -form validation
- Fast data entry (if you are doing mass data entry work) – Save both time and money
- Monitor data entry work real-time and let you make proactive decisions
- And so many…
All the above-mentioned app and services are packed with your Google Account completely free. So, you can build an absolutely free data entry form or any type of online form to perform CRUD Operations on Google Sheets. So, let’s get started.
In a previous post also, I explained, “How to Create Data Entry Form with Google HTML Service and Submit Data to Google Sheets“. However, using that code you can only write data to Google Sheets. If you only need to submit data to Google Sheets, you may use that method because that code is less complex than this.
What you need
Basic knowledge on HTML, CSS, JavaScript
Basic Knowledge on Google Apps Script
You need to have basic programming knowledge on HTML, CSS, and JavaScript to modify the code in this post. However, I will try my best to make the code readable and editable by non-programmers too.
Overview of creating an Online Data Entry Form that can Perform CRUD Operations on Google Sheets
In this tutorial, we are going to create a web form that can Create, Read, Update, and Delete (CRUD) records in Google Sheets.
For creating this online form I am using Google Apps Scripts. There are two ways that you can use Google Apps Scripts namely Container-bound Scripts and Standalone Scripts. Here I am using the Standalone Scripts. So you have to create Google Sheet and the App Script files separately in your Google Drive.
We are going to perform CRUD operations on Google Sheets using Google Sheets API v4. (in the previous post that I mentioned above create the HTML form without using APIs)
The Concept
To perform CRUD operations, you need to create a unique ID for your records. For this purpose, this script uses the current time in milliseconds (since 1970) as explains here.
I briefly explain the logic behind the CRUD operations used in this method below.
Create/ Insert Data
Fill the form and hit the submit button. If it passes the browser validation data is sent to the server-side script. If it is not an update request (does not contain an ID) server-side script adds a new id (it is the timestamp) and append data to the specified range.
Read Data
The server-side script request data for a given range using APIs. after you perform, create, update, or delete action the web app updates the data table in the frontend with changed data.
Update Data
When you click the update button, it passes the record ID to the server-side script. The server-side script validates the ID, and if it exists, it reads the relevant row. The data passes to the form for editing.
Once you hit the submit button, it passes data to the server-side script. It validates the ID and if it exists, updates the replace the relevant row with new data.
Delete Data
When you click the delete button, it passes the record ID to the server-side script. The server-side script validates the ID. If the ID exists, delete the relevant row and shift the cells up.
Live Demo
Use the following links to access the live form and the Data Sheet.
How to Create this online form using Google Apps Scripts and perform CRUD operations on Google Sheets
Here I am not going to explain the code line by line. Instead, I will briefly explain the purpose of each function, file, and present you the relevant code below.
If you are already familiar with Google Apps Script, you can copy the Google Apps Script file and the Google Sheet to your Google Drive from the following links and start modifying. I have added comments at all the locations that you need to change when you are adding new fields.
You need to change the Google Sheet ID (Spreadsheet ID) in the Apps Script file as explained below in order to send the data to Google Sheet.
The following video demonstrates how to copy these files to your Google Drive and run the code. In this video, from 2:15 onwards I am explaining how to add a new field to the form.
You can get a brief idea of the code following the below steps. I assume that you have already logged into your Google Account.
Step 01: Make a Copy of the Google Sheets
You can make a copy of the Google Sheets used in this example from the following link.
Link to Google Sheet – Make a copy to your Google Drive
This spreadsheet contains two sheets namely “Data” and “Helpers”. The data you inserted from the web form is saving to the “Data” Sheet. The “Helper” sheet includes a list of countries, that are required for populating the “Country” drop-down list.

Step 02: Make a Copy of the Google Apps Script File
You can also make a copy of the App Script used in this example file from the below link.
Link to Google Apps Script File – Make a copy to your Google Drive
The Apps Script file contain following files.
- Code.gs
- Index.html
- JavaScript.html
- Form.html
- DataTable.html
- CSS.htm
The Code.gs
file contains the server-side scripts, which includes the function that calls Google Sheets API. The other files make up the online form.
I have moved the HTML codes for form and the data table into separate files namely Form.html
and DataTable.html
files to make the code more readable. Those two files are included in the Index.html
file using include()
function in the Code.gs
file.
The JavaScript and CSS are written in the JavaScript.html
and CSS.html
files respectively. Those two files are also included in the Index.html file using the same include()
function mentioned above.
See the Google HTML Service guides on Separating HTML, CSS, and JavaScript
Code Snippets
The following are the codes included in the Google Apps Script file mentioned above.
1. Code.gs
The Code.gs file includes the server side functions.
Inside the function globalVariables()
, you can define all the variables used in the script. So, you can call them later inside the other functions when you need them.
Most of the functions are self-explanatory, and I have added comments to make it easy to understand. The sources of some code sections are also added in the comments.
I will explain how this code work later in this post.
/* # CREATED BY: BPWEBS.COM # URL: http://www.bpwebs.com */ function doGet(request) { return HtmlService.createTemplateFromFile('Index').evaluate(); } /* DEFINE GLOBAL VARIABLES, CHANGE THESE VARIABLES TO MATCH WITH YOUR SHEET */ function globalVariables(){ var varArray = { spreadsheetId : '1ZibOmtjn8RUlG-ULtj72INWCQx0Xt6ptGVrIAc3OrbM', //** CHANGE !!! dataRage : 'Data!A2:G', //** CHANGE !!! idRange : 'Data!A2:A', //** CHANGE !!! lastCol : 'G', //** CHANGE !!! insertRange : 'Data!A1:G1', //** CHANGE !!! sheetID : '0' //** CHANGE !!! Ref:https://developers.google.com/sheets/api/guides/concepts#sheet_id }; return varArray; } /* # PROCESSING FORM --------------------------------------------------------------------------------- */ /* PROCESS FORM */ function processForm(formObject){ if(formObject.RecId && checkID(formObject.RecId)){//Execute if form passes an ID and if is an existing ID updateData(getFormValues(formObject),globalVariables().spreadsheetId,getRangeByID(formObject.RecId)); // Update Data }else{ //Execute if form does not pass an ID appendData(getFormValues(formObject),globalVariables().spreadsheetId,globalVariables().insertRange); //Append Form Data } return getLastTenRows();//Return last 10 rows } /* GET FORM VALUES AS AN ARRAY */ function getFormValues(formObject){ /* ADD OR REMOVE VARIABLES ACCORDING TO YOUR FORM*/ if(formObject.RecId && checkID(formObject.RecId)){ var values = [[formObject.RecId.toString(), formObject.name, formObject.gender, formObject.dateOfBirth, formObject.email, formObject.phone, formObject.country]]; }else{ var values = [[new Date().getTime().toString(),//https://webapps.stackexchange.com/a/51012/244121 formObject.name, formObject.gender, formObject.dateOfBirth, formObject.email, formObject.phone, formObject.country]]; } return values; } /* ## CURD FUNCTIONS ---------------------------------------------------------------------------------------- */ /* CREATE/ APPEND DATA */ function appendData(values, spreadsheetId,range){ var valueRange = Sheets.newRowData(); valueRange.values = values; var appendRequest = Sheets.newAppendCellsRequest(); appendRequest.sheetID = spreadsheetId; appendRequest.rows = valueRange; var results = Sheets.Spreadsheets.Values.append(valueRange, spreadsheetId, range,{valueInputOption: "RAW"}); } /* READ DATA */ function readData(spreadsheetId,range){ var result = Sheets.Spreadsheets.Values.get(spreadsheetId, range); return result.values; } /* UPDATE DATA */ function updateData(values,spreadsheetId,range){ var valueRange = Sheets.newValueRange(); valueRange.values = values; var result = Sheets.Spreadsheets.Values.update(valueRange, spreadsheetId, range, { valueInputOption: "RAW"}); } /*DELETE DATA*/ function deleteData(ID){ //https://developers.google.com/sheets/api/guides/batchupdate //https://developers.google.com/sheets/api/samples/rowcolumn#delete_rows_or_columns var startIndex = getRowIndexByID(ID); var deleteRange = { "sheetId" : globalVariables().sheetID, "dimension" : "ROWS", "startIndex" : startIndex, "endIndex" : startIndex+1 } var deleteRequest= [{"deleteDimension":{"range":deleteRange}}]; Sheets.Spreadsheets.batchUpdate({"requests": deleteRequest}, globalVariables().spreadsheetId); return getLastTenRows();//Return last 10 rows } /* ## HELPER FUNCTIONS FOR CRUD OPERATIONS -------------------------------------------------------------- */ /* CHECK FOR EXISTING ID, RETURN BOOLEAN */ function checkID(ID){ var idList = readData(globalVariables().spreadsheetId,globalVariables().idRange,).reduce(function(a,b){return a.concat(b);}); return idList.includes(ID); } /* GET DATA RANGE A1 NOTATION FOR GIVEN ID */ function getRangeByID(id){ if(id){ var idList = readData(globalVariables().spreadsheetId,globalVariables().idRange); for(var i=0;i<idList.length;i++){ if(id==idList[i][0]){ return 'Data!A'+(i+2)+':'+globalVariables().lastCol+(i+2); } } } } /* GET RECORD BY ID */ function getRecordById(id){ if(id && checkID(id)){ var result = readData(globalVariables().spreadsheetId,getRangeByID(id)); return result; } } /* GET ROW NUMBER FOR GIVEN ID */ function getRowIndexByID(id){ if(id){ var idList = readData(globalVariables().spreadsheetId,globalVariables().idRange); for(var i=0;i<idList.length;i++){ if(id==idList[i][0]){ var rowIndex = parseInt(i+1); return rowIndex; } } } } /*GET LAST 10 RECORDS */ function getLastTenRows(){ var lastRow = readData(globalVariables().spreadsheetId,globalVariables().dataRage).length+1; if(lastRow<=11){ var range = globalVariables().dataRage; }else{ var range = 'Data!A'+(lastRow-9)+':'+globalVariables().lastCol; } var lastTenRows = readData(globalVariables().spreadsheetId,range); return lastTenRows; } /* GET ALL RECORDS */ function getAllData(){ var data = readData(globalVariables().spreadsheetId,globalVariables().dataRage); return data; } /* ## OTHER HELPERS FUNCTIONS ------------------------------------------------------------------------ */ /*GET DROPDOWN LIST */ function getDropdownList(range){ var list = readData(globalVariables().spreadsheetId,range); return list; } /* INCLUDE HTML PARTS, EG. JAVASCRIPT, CSS, OTHER HTML FILES */ function include(filename) { return HtmlService.createHtmlOutputFromFile(filename) .getContent(); }
2. Index.html
I am using the Bootstrap framework for styling the page. I have included it in the header section of the Index.html
using BootstrapCDN. The JavaScript.html
, CSS.html
, Form.html
and DataTable.html
files are included using <?!= include('file_name'); ?>
code in 8,9,15 and 20 lines of the following code snippet.
<!DOCTYPE html> <html> <head> <base target="_top"> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js" integrity="sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o" crossorigin="anonymous"></script> <?!= include('JavaScript'); ?> <!-- See JavaScript.html file --> <?!= include('CSS'); ?> <!-- See CSS.html file --> </head> <body onload="createCountryDropdown()"> <div class="container"> <div class="row"> <div class="col-lg-6"> <?!= include('Form'); ?> <!-- See Form.html file --> <br><br> <div id="output"></div> </div> <div class="col-lg-6"> <?!= include('DataTable'); ?> <!-- See DataTable.html File --> </div> </div> </div> </body> </html>
3. JavaScript.html
<script> // Prevent forms from submitting. function preventFormSubmit() { var forms = document.querySelectorAll('form'); for (var i = 0; i < forms.length; i++) { forms[i].addEventListener('submit', function(event) { event.preventDefault(); }); } } window.addEventListener("load", functionInit, true); //INITIALIZE FUNCTIONS ONLOAD function functionInit(){ preventFormSubmit(); getLastTenRows(); }; //HANDLE FORM SUBMISSION function handleFormSubmit(formObject) { google.script.run.withSuccessHandler(createTable).processForm(formObject); document.getElementById("myForm").reset(); } //GET LAST 10 ROWS function getLastTenRows (){ google.script.run.withSuccessHandler(createTable).getLastTenRows(); } //GET ALL DATA function getAllData(){ //document.getElementById('dataTable').innerHTML = ""; google.script.run.withSuccessHandler(createTable).getAllData(); } //CREATE THE DATA TABLE function createTable(dataArray) { if(dataArray){ var result = "<table class='table table-sm' style='font-size:0.8em'>"+ "<thead style='white-space: nowrap'>"+ "<tr>"+ //Change table headings to match witht he Google Sheet "<th scope='col'>Delete</th>"+ "<th scope='col'>Edit</th>"+ "<th scope='col'>ID</th>"+ "<th scope='col'>Name</th>"+ "<th scope='col'>Gender</th>"+ "<th scope='col'>Date of Birth</th>"+ "<th scope='col'>Email</th>"+ "<th scope='col'>Phone</th>"+ "<th scope='col'>country</th>"+ "</tr>"+ "</thead>"; for(var i=0; i<dataArray.length; i++) { result += "<tr>"; result += "<td><button type='button' class='btn btn-danger btn-xs deleteBtn' onclick='deleteData(this);'>Delete</button></td>"; result += "<td><button type='button' class='btn btn-warning btn-xs editBtn' onclick='editData(this);'>Edit</button></td>"; for(var j=0; j<dataArray[i].length; j++){ result += "<td>"+dataArray[i][j]+"</td>"; } result += "</tr>"; } result += "</table>"; var div = document.getElementById('dataTable'); div.innerHTML = result; document.getElementById("message").innerHTML = ""; }else{ var div = document.getElementById('dataTable'); div.innerHTML = "Data not found!"; } } //DELETE DATA function deleteData(el) { var result = confirm("Want to delete?"); if (result) { var recordId = el.parentNode.parentNode.cells[2].innerHTML; google.script.run.withSuccessHandler(createTable).deleteData(recordId); } } //EDIT DATA function editData(el){ var recordId = el.parentNode.parentNode.cells[2].innerHTML; //https://stackoverflow.com/a/32377357/2391195 google.script.run.withSuccessHandler(populateForm).getRecordById(recordId); } //POPULATE FORM function populateForm(records){ document.getElementById('RecId').value = records[0][0]; document.getElementById('name').value = records[0][1]; document.getElementById(records[0][2]).checked = true; document.getElementById('dateOfBirth').value = records[0][3]; document.getElementById('email').value = records[0][4]; document.getElementById('phone').value = records[0][5]; document.getElementById("country").value = records[0][6]; document.getElementById("message").innerHTML = "<div class='alert alert-warning' role='alert'>Update Record [ID: "+records[0][0]+"]</div>"; } //RETRIVE DATA FROM GOOGLE SHEET FOR COUNTRY DROPDOWN function createCountryDropdown() { //SUBMIT YOUR DATA RANGE FOR DROPDOWN AS THE PARAMETER google.script.run.withSuccessHandler(countryDropDown).getDropdownList("Helpers!A1:A195"); } //POPULATE COUNTRY DROPDOWNS function countryDropDown(values) { //Ref: https://stackoverflow.com/a/53771955/2391195 var list = document.getElementById('country'); for (var i = 0; i < values.length; i++) { var option = document.createElement("option"); option.value = values[i]; option.text = values[i]; list.appendChild(option); } } </script>
4. Form.html
<!-- ## The html code of the form goes here --> <!-- ## This is included in the Index.html page using "include('Form')" function --> <form id="myForm" class="p-2 border border-light rounded bg-light" onsubmit="handleFormSubmit(this)"> <!-- Call JavaScript function "handleFormSubmit" --> <p class="h4 mb-4 text-center">Contact Details Form</p> <div id="message"></div> <input type="text" id="RecId" name="RecId" value="" style="display: none"> <div class="form-group"> <label for="name" >Name</label> <input type="text" class="form-control" id="name" name="name" placeholder="Name" required> </div> <div class="form-row"> <div class="form-group col-md-6"> <p>Gender</p> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="gender" id="male" value="male"> <label class="form-check-label" for="male">Male</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="gender" id="female" value="female"> <label class="form-check-label" for="female">Female</label> </div> </div> <div class="form-group col-md-6"> <label for="dateOfBirth">Date of Birth</label> <input type="date" class="form-control" id="dateOfBirth" name="dateOfBirth"> </div> </div> <div class="form-group"> <label for="email">Email</label> <input type="email" class="form-control" id="email" name="email" placeholder="Email"> </div> <div class="form-row"> <div class="form-group col-md-6"> <label for="phone">Phone Number</label> <input type="tel" class="form-control" id="phone" name="phone" placeholder="Phone Number"> </div> <div class="form-group col-md-6"> <label for="exampleFormControlSelect1">Country</label> <select class="form-control" id="country" name="country"> <option>Select Country</option> </select> </div> </div> <button type="submit" class="btn btn-primary">Submit</button> <input class="btn btn-secondary" type="reset" value="Reset"> </form>
5. DataTable.html
The data table is inserted by JavaScript function inside id dataTable
.
<p class="h4 mb-4 text-center">Contact Details Database</p> <div id="dataTable" class="table-responsive"> <!-- The Data Table is inserted here by JavaScript --> </div> <br> <button type="button" class="btn btn-success btn-sm" onclick="getAllData()">Get ALL Data</button>
6. CSS.html
The following CSS class change the button size. You can add your custom CSS inside the following file.
<style> .btn-group-xs > .btn, .btn-xs { padding: .25rem .4rem; font-size: .875rem; line-height: .5; border-radius: .2rem; } </style>
Step 03: Change the SpreadsheetID in Code.gs file
Copy the spreadsheetID
of the google sheet, you copied to your drive in Step 01. Replace the spreadsheetId in line 15 of Code.gs file.
Learn how to find spreadsheetID.
Step 04: Enable Google Sheets API
You must enable Google Sheets API in Advance Google Services to run this script. To enable Google Sheets API for you Apps Script,
- Open the Script Editor (the file you copied to Google Drive in Step 02)
- Go to Resources > Advanced Google services….
- In the Advanced Google Service dialog box, go down and enable Google Sheets API
- Click Ok
Step 05: Deploy as a Web App
To deploy this script as a web app.
- In the Script Editor, Go to Publish > Deploy as web app
- In the Deploy as web app dialog, select Project Version as New.
- Under Execute the app as: select your email address.
- under Who has access to the app, select your preference.
- Click Deploy.
- In the next dialog box, copy the Current web app URL
- Paste it in your browser and your online form will be loaded.
Read more about Deploying a script as a web app in Google Guide.
How this Script perform CRUD Operations on Google Sheets
Create New Record
- After you correctly fill the form and hit the submit button, the function
handleFormSubmit()
in the JavaScript file is called. - This function calls the function
processForm()
in the Code.gs file and passes the form object as the parameter. - The function
processForm()
check whether form object has an ID (RecID
) and if exist validate usingcheckID()
function. - If the form object does not have a valid
recId
, the functionappendData()
is called. - The function
getFormValues()
(the first parameter of theappendData()
function) process the form object and returns a value array. It also creates a new ID ifrecId
not exists. - The function
appendData()
is executed and append the form data ta to the given range. - Then the function
processForm()
call the functiongetLastTenRows()
and it returns the last 10 rows of your data range. The function processForm() also return the same to thehandleFormSubmit()
mentioned in no 1 above. - Then the JavaScript function
handleFormSubmit()
call the functioncreateTable()
function with the last 10 rows as a parameter. - Then the function
createTable()
update the data table next to the Form.
Update Record
- The user clicks the update button in the row which data need to be updated.
- It calls the
editData()
JavaScript function which you can see in the JavaScript file. - Then, the function
editData()
call the serverside functiongetRecordById()
(it is in the Code.gs file) with therecId
as the parameter. - The
getRecordById()
returns the relevant row of data as an array to theeditData()
function. - Then, the
editData()
function calls the JavaScript functionpopulateForm()
with the data array (it is in the JavaScript file). - The function
populateForm()
populates the form fields with the data. - Then the user can make the changes and hit the submit button.
- Hereafter, almost the same process in the above “Create New Record” is followed. Since here form passes a
recId
, in step 4 it calls theupdateData()
function. It replaces the row which matches therecId
.
Delete Data
- The user clicks the Delete button in the row which data need to be deleted.
- Browser request to confirm the action.
- It calls the JavaScript function
deleteData()
which you can see in the JavaScript file. - Then, the function
deleteData()
calls the serverside functiondeleteData()
(the second is in the Code.gs file) with therecId
as the parameter. - The serverside function
deleteData()
validate and delete the row that matches therecId
. After deleting the record function returns the last 10 records of the data range. - Then the JavaScript function
deleteData()
(the function in the JavaScript file) calls the functioncreateTable()
with the last 10 rows as a parameter. - Then the function
createTable()
updates the data table next to the Form.
Form Validation
Form validation is very important when submitting data to Google Sheets. For form validation, I have used browser defaults. However, depending on the requirements you may need more customization. You can learn more about Bootstrap form validation from this link.
What Next
This form covers most of the common form elements that you need to build a data entry form or any type of online form to perform CRUD operations on Google Sheets. So, you can customize this form to match with your requirements using those elements. You can learn more about this using the links provided in this article as well as from the URLs commented in the code.
When you have data on your hand, you must use data visualization techniques to spot the signals in your data. If you can build an online dashboard for your data, you can make decisions even while your data collection project is ongoing. You can learn more about building a free online dashboard from my previous post, “How to Create an Online Dashboard for free to Share and Visualize Your Data“.
Wrapping Up
Google Apps Scripts has introduced to increase the power of your favorite Google apps. So, by using Google Apps Script with Google Apps you can build various types of custom solutions to boost your collaboration and productivity.
In this example, I explained to you how to build an Online Data Entry Form that can Perform CRUD Operations on Google Sheets. Where I used Google Sheets APIs with Google Apps Script HTML service. I have added most of the form elements that required to build most of the forms used in your day to day works. So, you can expand this form to meet your requirements even if you do not have much knowledge of coding.
ask, why when i dont use delete button i cant use teh edit button, and how to show 10 first data with next button ?
Thank you so much. This is really a great script! I customized the fields and sheet and it works perfectly. I want to use this to keep track of participants and results of sailing races on a small non-professional scale. Just getting this working is already fun. My next challenge is a ‘dynamic dropdown’ where the selectable are based on the selection from the previous dropdown. Instead of ‘countries’ I have ‘participants’ and ‘boats’ in an n-n relation. Participants can sail different boats and boats can have different participants.
Sheet-tab name = ‘participant’
1st dropdown = Spreadsheet column A ‘participant’
2nd dropdown = spreadsheet column B ‘boat’
So in the 1st dropdown I select the participant. In the 2nd dropdown I want to be able to select only the boats (column B) based on the selected participant from column A.
How do I get that done? Thanks in advance! Here is the script:
//RETRIVE DATA FROM GOOGLE SHEET FOR PARTICIPANT DROPDOWN
function createparticipantDropdown() {
//SUBMIT YOUR DATA RANGE FOR DROPDOWN AS THE PARAMETER google.script.run.withSuccessHandler(participantDropDown).getDropdownList(“participant!A2:A195”);
}
//POPULATE PARTICIPANT DROPDOWN
function participantDropDown(values) { //Ref: https://stackoverflow.com/a/53771955/2391195
var list = document.getElementById(‘participant’);
for (var i = 0; i < values.length; i++) {
var option = document.createElement(“option”);
option.value = values[i];
option.text = values[i];
list.appendChild(option);
}}
//RETRIVE DATA FROM GOOGLE SHEET FOR BOAT DROPDOWN
function createboatDropdown() {
//SUBMIT YOUR DATA RANGE FOR DROPDOWN AS THE PARAMETER
google.script.run.withSuccessHandler(boatDropDown).getDropdownList(“participant!B2:B195”);
}
//POPULATE BOAT DROPDOWN
function boatDropDown(values) { //Ref: https://stackoverflow.com/a/53771955/2391195
var list = document.getElementById(‘boat’);
for (var i = 0; i < values.length; i++) {
var option = document.createElement(“option”);
option.value = values[i];
option.text = values[i];
list.appendChild(option);
}}
How would I add here a dependent dropdown list?
Thank you so much.
why all the data does not show up when i click on get all data?
how can i change the id to entry id and not a
random Id?
This is not a random ID. It’s the current time in milliseconds (from 1970).
If you want to create your own ID,
– Create a new text field as explain in this video
– Then change line 53 of Code.gs (
new Date().getTime().toString()
) accordingly.Ex: formObject.id (if your text field name is “id”)
– Make sure you do not insert duplicate Ids
@Bpweb Is there any possibility to save users’ responses to continue on a later pit before submitting into the database?
why the dateofbirth insert to googlesheet in format yyyy-mm-dd
How can i insert in format yyyy/mm/dd?
@BPWEB Team: Is there anyway to pick-up a checkbox value with the getFormValues(formObject) function?
Great approach! Would it be possible to make the functions
createCountryDropdown(), countryDropDown(values)
that dynamic that we can use it for multiple dropdowns (instead of just country)?
This is amazing. One question : Can we implement authentication and authorization ? E.g. User can only edit or delete his/her own row ? is it possible ?
hey is it possible to completely remove the id system so when I create a new one, an Id isn’t created?