Javascript for parsing submitted form returning variable

tkosker1029
tkosker1029 Community Member Posts: 26
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?

Comments

  • klaatu
    klaatu Community Member Posts: 988
    VaSchool.set(RetValue[0]);  Typo - missing the "r" in Var?
  • tkosker1029
    tkosker1029 Community Member Posts: 26
    Thanks a lot Missed that.
  • tkosker1029
    tkosker1029 Community Member Posts: 26
    When I have another action after run Javascript Action they don't seem to run. Do you have any estimation?
  • klaatu
    klaatu Community Member Posts: 988
    Do you have an example?
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916
    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
  • tkosker1029
    tkosker1029 Community Member Posts: 26
    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?

     
Sign In or Register to comment.

So You Wanna Be An eLearning ROCKSTAR?

We're all fans of eLearning here! Want to become an eLearning ROCKSTAR? Just click on one of the buttons below to start your rocking journey!