Posting storyline variables to Google Spreadsheet

Hello,

I have been researching high and low, but I'm having the toughest challenge trying to get a few storyline variables written to a Google spreadsheet.  I am not a programmer, but I think I've got it on the right track.  I would be most grateful for anyone who might be able to help.

I am not using an embedded Google form, I'm simply trying to pass the values of three storyline variables to a Google Spreadsheet.

Google spreadsheet URL: https://docs.google.com/a/hubbardswim.com/spreadsheet/ccc?key=0Atly3766dLx3dFI2YUNHcnNQSXZZSlU1YWs4RGRGNlE&usp=drive_web#gid=0

In the <head> of my story.html file I have added a couple of lines:

<script src="story_content/postGoogle.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

the postGoogle.js file is located in the "story_content" folder on my server.  I have a "submit to google" button setup in storyline, with a trigger that calls for the following javascript to be executed onClick:

var player = GetPlayer();
postContactToGoogle();

I'm making the estimation that Storyline is using the names given to objects/fields in the project as "id" tags that can be referenced in JavaScript (the same way you would for an HTML page).  This might be one of my errors.  Based on this assumption, I have a text entry field named "txt_firstName" where a user inputs their first name.  I'm using '#txt_firstName' to get the variable value in my postContactToGoogle function.

I do have triggers set up for txt_firstName and txt_lastName to set the new variables (firstName and lastName) to the typed value when the control loses focus.

On my postGoogle.js file it looks as such:

    function postContactToGoogle(){
        var firstName = $j('#txt_firstName').val();
        var lastName = $j('#txt_lastName').val();
        var Results.ScorePercent = $j('#txt_yourGrade').val();

{
            $j.ajax({
                url: "https://docs.google.com/forms/d/0Atly3766dLx3dFI2YUNHcnNQSXZZSlU1YWs4RGRGNlE/formResponse",
                data: {"entry.1" : firstName, "entry.2" : lastName, "entry.3": Results.ScorePercent},
                type: "POST",
                dataType: "xml",
                statusCode: {  //redirect to thank you page if 0 or 200

Full postGoogle.js file attached.

Many thanks for any help and/or guidance.

5 Replies