Sending variables out to a URL using the post request.

Aug 22, 2013

I’m working on a project and need to send out some variables that have been captured within the course out to an external URL .  The client has a tracking system that will accept the information using a post request to a URL, the example below was provided:

http://thisisthedestinationurl.aspx?USER_EMAIL=testemail.com&FIRST_NAME=Bob&LAST_NAME=Smith&COUNTRY=UK&COURSE_ID=Programming&DIVISION=IT

As far as I understand I can put a button with a trigger that will execute some JavaScript code and post out the information.  I have been able to find the below code on the forum but have no idea if this is the way to go.

var sHTML = "";

sHTML += "<form id='formScore' method='post' action='http://p2.hawaiiantel.com/hr/Storyline/SL_Login2.asp'>";

sHTML += "<input type='hidden' id='Title' name='Title' value= " + title + ">";

sHTML += "<input type='hidden' id='Result' name='Result' value= " + resultstatus + ">";

sHTML += "<input type='hidden' id='ScorePctg' name='ScorePctg' value= " + scorepctg + ">";

sHTML += "<input type='hidden' id='ScorePoints' name='ScorePoints' value= " + scorepoints + ">";

sHTML += "<input type='hidden' id='PassingPctg' name='PassingPctg' value= " + passingpctg + ">";

sHTML += "<input type='hidden' id='PassingPoints' name='PassingPoints' value= " + passingpoints + ">";

sHTML += "<br><input type='submit'><br>";

sHTML += "<form>";

document.getElementById("divEmail").innerHTML = sHTML;

document.getElementById("formScore").submit();

My JavaScript skills are limited, and when I say limited I mean none existent.

Any help will be very much appreciated.

Thanks

Stephen

4 Replies
Dennis Hall

Hi Stephan:

From the looks of it, the script above is opening a page Hawaiian Telcom page, going to a course for a specific title, and providing SL information.

Is this to send your story results (via the hidden form) from the currently open one over port 443?

If yes, this should work, you will need to do a great deal of testing.

You need to pay attention to your variable naming in the string. Example: "passingpoints" or "PassingPoints".

Hope this helps.

Best Regards,

Dennis Hall

Stephen Cope

Thanks Dennis,

 The scrip ‘Hawaiian Telcom’ is something that I grabbed off the forum, and is the nearest thing I could find to what I need to do.

 The client provided this as an example of what the URL will except ;

http://thisisthedestinationurl.aspx?USER_EMAIL=testemail.com&FIRST_NAME=Bob&LAST_NAME=Smith&COUNTRY=UK&COURSE_ID=Programming&DIVISION=IT

I need to know how to send this out.

If I changed the code to something like the below would that send out the course variables to the URL?

Course variables = email, firstname and lastname

 var sHTML"";

sHTML +="form id ='formCourseInfo' method='post'action='URL Address goes here'>";

sHTML +="<input type="hidden' id='USER_EMAIL' name='USER_EMAIL' value ="+email+">";

and so on until I have added all of the variables that I need to send.

Stephen Cope

Thanks again Dennis

I understand how to create my variables in storyline and I can attach a trigger to the last slide to execute the code above.

I also understand the line of code that creates the form and posts to the URL and the lines underneath that will attach the variables, but do I need to include the following code at the end?

sHTML+="

";

sHTML +="";

document.getElementbyId("divEmail").innerHTML=sHTML;

document.getElementById("formScre").submit();

this code was at the bottom of the example code I found on the forums.

Regards

Stephen.

This discussion is closed. You can start a new discussion or contact Articulate Support.