Calculating Remainders

akrayenhagen9721
akrayenhagen9721 Community Member Posts: 23
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?

Comments

  • klaatu
    klaatu Community Member Posts: 988
    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.
  • akrayenhagen9721
    akrayenhagen9721 Community Member Posts: 23
    Sorry, Here you go.
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916
    Questions like these i often use to improve my own portfolio. This time again.
    http://community.trivantis.com/shared-content/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...
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!