Explore the community Forums Lectora Lectora Questions & Answers Javascript for parsing submitted form returning variable

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #345422 Score: 0
    Profile photo of tamer kosker
    tamer kosker
    Member
    beginner
    intermediate
    contributor
    wise owl
    curious george
    @tkosker1029

    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?

    #345429 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    129 pts
    @Klaatu

    VaSchool.set(RetValue[0]);  Typo – missing the “r” in Var?

    #345431 Score: 0
    Profile photo of tamer kosker
    tamer kosker
    Member
    beginner
    intermediate
    contributor
    wise owl
    curious george
    @tkosker1029

    Thanks a lot Missed that.

    #345446 Score: 0
    Profile photo of tamer kosker
    tamer kosker
    Member
    beginner
    intermediate
    contributor
    wise owl
    curious george
    @tkosker1029

    When I have another action after run Javascript Action they don’t seem to run. Do you have any estimation?

    #345459 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    129 pts
    @Klaatu

    Do you have an example?

    #345473 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    56 pts
    @mnotermans5114

    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

    #347260 Score: 0
    Profile photo of tamer kosker
    tamer kosker
    Member
    beginner
    intermediate
    contributor
    wise owl
    curious george
    @tkosker1029

    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?

     

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.