Simple polls backed by google sheets.
This is completely not a secure way to do polling, but it's quick, easy, and doesn't require a database table.
- google sheets
- jquery
- chartjs
- Create a blank google sheet which will hold your results. The rows will correspond to each poll question while the columns will correspond to the choices.
- Open up the script editor in google sheets with
Tools>Script Editor - Clear out the boilerplate script in the script editor and copy/paste everything from appScript.js
- Save the script, then go to
Run> selectsetup - You'll be prompted to grant authorization to the script so agree to that.
- Go to
Publish>Deploy as web app - Important: Change "Who has access to the app:" to "Anyone, even anonymous".
- Click
Deploy - You'll be presented with a URL for the web app. Copy that.
- Paste the above URL into the
APP_URLvariable of demo.html - Close the script editor now and go back to your google sheet.
- Get the google sheet key (from the URL) and paste it into the
SHEET_IDvariable. - You can create polls by changing the values in the
pollContentvariable of demo.html:var pollContent = [ { question: 'Dogs or cats?', choices: [ 'dog', 'cat' ] }, { question: 'Cake, pie, or ice cream?', choices: [ 'cake', 'pie', 'ice cream' ] }, { question: 'Do you like the Oxford comma?', choices: [ "Yes, I'm pretentious", "Is that a soccer team?" ] } ]; - The rest of the javascript in demo.html deals with building the poll HTML programatically as well as fetching the results and feeding it into chart.js
Credit goes to these two tutorials which sparked this idea: https://medium.com/@dmccoy/how-to-submit-an-html-form-to-google-sheets-without-google-forms-b833952cc175 https://medium.com/dali-lab/google-sheets-and-json-easy-backend-e29e9ef3df2