1

I have Lname Fname input and I want to send its value to google spreadsheet. how do I do that? Can u please provide some simple ways or tutorials for newbie. Guide on google api developer too confusing

Random Things
  • 21
  • 1
  • 2
  • 4

1 Answers1

4

<!DOCTYPE html>
<html>
    <head>
        <title>Test Google Forms</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    </head>
    <body>
        <div>
            <div>
                <strong>Test Google Form</strong>
            </div>
            <form id="form" target="_self" onsubmit="" action="">
                <fieldset>
                    <label>Question 1</label>
                    <input id="qs1_op_1" type="radio" value="Yes" name="qs1">
                    <input id="qs1_op_2" type="radio" value="No" name="qs1">
                </fieldset>
                <fieldset>
                    <label>Question 2</label>
                    <input id="qs2_op_1" type="radio" value="Yes" name="qs2">
                    <input id="qs2_op_2" type="radio" value="No" name="qs2">
                </fieldset>
                <fieldset>
                    <label>Text</label>
                    <textarea id="feed" name="feed"></textarea>
                </fieldset>
                <div style="width: 100%; display: block; float: right;">
                    <button id="send" type="submit">
                        Send
                    </button>
                </div>
            </form>
        </div>
        <script type="text/javascript">
            function postToGoogle() {
                var field1 = $("input[type='radio'][name='qs1']:checked").val();
                var field2 = $("input[type='radio'][name='qs2']:checked").val();
                var field3 = $('#feed').val();
 
                $.ajax({
                    url: "https://docs.google.com/forms/d/FORM_KEY/formResponse",
                    data: {"entry.1023121230": field3, "entry.1230072460": field1, "entry.2113237615": field2},
                    type: "POST",
                    dataType: "xml",
                    statusCode: {
                        0: function() {
                            //Success message
                        },
                        200: function() {
                            //Success Message
                        }
                    }
                });
            }
             
            $(document).ready(function(){
                $('#form').submit(function() {
                    postToGoogle();
                    return false;
                });
            });
        </script>
    </body>
</html>

For more detils check these links https://wiki.base22.com/pages/viewpage.action?pageId=72942000

http://quandaflow.com/

Ananta Prasad
  • 3,655
  • 3
  • 23
  • 35
  • It updates correctly. But throwing a cross-origin error in the response. Is any headers missed in this? – Anbu Aug 24 '18 at 17:28