Tagged: ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #391863 Score: 0
    Profile photo of Andy Krayenhagen
    Andy Krayenhagen
    Member
    beginner
    intermediate
    advanced
    picture perfect
    profile
    friend finder
    curious george
    wise owl
    contributor
    2 pts
    @akrayenhagen9721

    Okay Ladies and Gents,

    I’m asking for help once again, as I am not proficient in JavaScript. Here is my dilemma, I am trying to do math in Lectora and output answers based on the answer. But the problem is that I can’t figure out how to calculate the remainder. Attached you will see an image of the calculations being performed.

    So lets say that I have a ceiling of 120. In line one I want to request 50 seats. So it should look like this…

    Req/Rel | Enter Seats | Total Req | Total Rel | Total Aloc | RH Aloc | RH Avail | RHREA Req | RHREA Rel

    Req                  50                   2                    0                 120               48               48                 2                         0

    So as you can see, we are requesting 50 seats (Enter Seats), but with a ceiling of 120 seats (Total Aloc) that leaves 2 seats left (RHREA Req)  to be held because there are only 48 available seats (RH Aloc | RH Avail).

    Can anyone help me?

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

    It would be beneficial when asking for help if you included something to work off of instead of having to recreate your issue or some other sample.

    #391880 Score: 0
    Profile photo of Andy Krayenhagen
    Andy Krayenhagen
    Member
    beginner
    intermediate
    advanced
    picture perfect
    profile
    friend finder
    curious george
    wise owl
    contributor
    2 pts
    @akrayenhagen9721

    Sorry, Here you go.

    Attachments:
    1. Test.zip
    #391954 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
    131 pts
    @mnotermans5114

    Questions like these i often use to improve my own portfolio. This time again.

    Seats Calculator


    I am planning to improve this setup and add animations for the elements to it, but thats for a next version. This version for now shows how to handle a calculation for remaining amount quite fine.
    Only thing you really need from it is parts of the ‘ReserveSeats’ function in the external Javascript.
    What you need to learn to use it…
    – How to read variables from Lectora ->  VarEntry_0001.getValue()
    – How to write variables to Lectora ->VaramountOfAvailableSeats.set(endResult);
    – How to use if/then statements to make a check and do something -> lines 18-30
    – How to target elements in Lectora -> in this case getHTMLNamesFromLectora() gets all seats in an Array to handle it. Quite a few different options for that shown in the forum here. This option is good when you have masses of images to handle and want to get it done without having to bother about their HTMLName. For now there are 24 seats in this aircraft. I am gonna add more, so then this function comes handy.
    – How to target a Group in Lectora -> runGroup_og18013()
    – How to calculate -> endResult  = Number(amountOfAvailableSeats) – Number(amountOfSeatsRequested);
    Lectora variables are strings. So you have to make numbers of them before you do any calculation.

    Well i do hope this helps you on the right track…

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

You must be logged in to reply to this topic.