Javascript for parsing submitted form returning variable
February 11, 2017 12:00 AM
Hello,
I have a form submitted to get user credentials from mysql db. And returned variable is retrieved. The returning value is something like this.
"SchoolName,StudentName,Permitted,LastLoginDate"
I want to parse this value into variables splitted by ","
I am using the following code in Run Javascript module of a button.
varRetValue = VarReturnedValue.getValue().split(",",2);
VaSchool.set(RetValue[0]);
VarStudent.set(RetValue[1]);
....
But the code does not function. Any ideas why it doesn't work?
Discussion (6)
VaSchool.set(RetValue[0]); Typo - missing the "r" in Var?
When I have another action after run Javascript Action they don't seem to run. Do you have any estimation?
Allthough i am not sure if this is the one causing the error, i see another typo/error in the code.
In the split you are ( at least it looks like ) filling the array varRetValue with the received values..
But then when calling a specific value of that array you use RetValue.
I like to use names for variables that specify what type it is.
So i do think it should be something like this ( if it is a typo and not just a missing space in the post )
var RetArray = VarReturnedValue.getValue().split(“,”,2);
VarSchool.set(RetArray[0]);
VarStudent.set(RetArray[1]);
or like you have it with just a added space.
varRetValue = var RetValue
Regards,
Math
Thanks for your great help.
Do you have any code samples of a javascript to retrieve completed pages count into a variable from TOC content without using LMS or scorm?
undefined
Discussions have been disabled for this post