0

It seems I have it almost working, but for some reason when I'm trying to submit data from an input field to a Google spreadsheet, it does add data, but not the data that is being inputed. So in the Google spreadsheet I see a new entry with timestamp, but not the inputed data.

Here's the code:

<script>
$('#emailForm').one('submit',function(){
    var inputField = encodeURIComponent($('#emailForm').val());
var baseURL = 'http://docs.google.com/forms/d/1vl7imylKoya3y8bnboD7WTQ5VsdVw1YmDA1-3_66Apo/formResponse?entry.1017875735=';
var submitRef = '&submit=Submit';
var submitURL = (baseURL + emailAddress + submitRef);
$(this)[0].action=submitURL;
$('#email').addClass('active').val('Thank You!');
setTimeout(function(){
  $('#form-container').hide();
  $('#update-form').animate({'width': '0px'},300,function(){
    $('#get-updates-link').hide();
      $('#email').addClass('active').val('Thank You!');
  });
},1000); 
</script>



<form action="https://docs.google.com/forms/d/1vl7imylKoya3y8bnboD7WTQ5VsdVw1YmDA1-3_66Apo/formResponse?entry.1017875735="

<form id="emailForm" action="" method="POST" target="no-target">
  <input id="email" type="email" placeholder="enter email" name="email">
  <button id="email-submit" type="submit"></button>
</form> 
Rubén
  • 34,714
  • 9
  • 70
  • 166
jibly
  • 115
  • 1
  • 13
  • 1
    The question is a bit silly, but where are you using the 'inputField' variable? To my understanding, this variable contains the value of the input field, but it is not sent to the Spreadsheet... – Rivero Mar 09 '15 at 22:08
  • It seems like the line should be `var emailAddress = encodeURIComponent($("#email").val());`. – Austin Mullins Mar 09 '15 at 22:18
  • FWIW: Here's [a fiddle](http://jsfiddle.net/amullins/at47xc3t/) I used to test the code. Unfortunately, JSFiddle doesn't handle forms well. I couldn't prevent the default submission action, but I could use a keyup event to see that data is getting in the right place. – Austin Mullins Mar 09 '15 at 22:39

1 Answers1

0

You've defined the var inputField, but later during submission, you've used emailAddress in your submitURL code line.

Sreetam Das
  • 3,226
  • 2
  • 22
  • 36