From 1db9e945659115069365edc9471b31cacc77ef1d Mon Sep 17 00:00:00 2001 From: Peter Jackson Date: Tue, 14 Oct 2014 00:58:33 -0400 Subject: [PATCH 1/4] Decouple the form submit javascript from the form input fields. --- index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.html b/index.html index 7ef9cbe..ebfe566 100644 --- a/index.html +++ b/index.html @@ -17,10 +17,9 @@ From b98cf738b61b6c604f7e84893d5c5346a5c28088 Mon Sep 17 00:00:00 2001 From: Peter Jackson Date: Tue, 14 Oct 2014 01:25:18 -0400 Subject: [PATCH 4/4] Update readme to match updated javascript --- README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 577f334..a49e2dc 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,14 @@ Submit to a google spreadsheet using a form of your own design. * Now view the source of your question input field, and copy the `name` attribute, ex: `entry.1000000`. Do the same with the submit button, ex: ``. -* Replace the `baseURL` in the index.html file with the form action URL you copied from your Google Form. - -* Replace the `submitRef` variable in the index.html file with the name and value from your submit button, ex: `&submit=Submit`. - -* In our form, we are collecting names, so we've given our form an ID of `input-form` and we've given our field an ID of `input-name`. You should change this to whatever information you are collecting in your form, and change the javascript so that JQuery is grabbing the right field's value. For example, if your form has an ID of `emailForm` and your field has an ID of `input id="emailField"` your javascript should be changed to: +* Make sure references to '#input-form' are changed to match the ID of your form. For example, if your form has an ID of `emailForm` your javascript should be changed to: ``` $('#emailForm').one('submit',function(){ - var inputField = encodeURIComponent($('#emailField').val()); - ... - $('#email').addClass('active').val('Thank You!'); + var submitURL = ($('#emailForm').attr('action') + '?' + $('#emailForm').serialize()); + $(this)[0].action = submitURL; }); + ``` * Style your page how you like, put in any sort of behavior you want to have happen when someone submits an entry (we're just having the form field say 'Thank You!'), then put these files on a web server somewhere, and you should now be able to submit data to your custom form, and see it appear in your Google Spreadsheet.