Explore the community Forums Lectora Lectora Questions & Answers Formatting in-line variables Reply To: Formatting in-line variables

#421606 Score: 0
Profile photo of Lydia B
Lydia B
Member
beginner
intermediate
curious george
wise owl
friend finder
contributor
@lb1730

Thank you for looking at this. And please forgive my ignorance. As I mentioned, JavaScript is a bit of a “black magic” for me at this time.

It seems that in your file, the script “translate” the string of numbers into a formatted number while it is triggered by pressing of the button, the “event”.  I tried to adjust it to use it in my file on “show”, but I was unsuccessful. Again, probably because I am just learning, so please be patient with me.

I need the number to be formatted in the text-box, when the question loads. Secondly, if I can format the input into the entry field triggered by the student just entering the number it would be perfect.

I am not sure whether I am explaining this clearly, so I am attaching one of the questions I am working on, hopefully, that will help. In this question, I have inline variables A1 to A6 in the text-boxes. These variables will be used by the student to calculate the balance in the account. They are only displayed by the program. I hope to have them shown with the comma separators.

Then student will input the answer into the entry field and I hope to have that field format the number automatically on input. So, the number would be shown with commas and aligned to the right. I was able to use your code to do that, however, it only works for numbers lower than 10,000. See the actions attached to Entry_DR_Bal. Perhaps, I changed something I should not have.

Thank you so much for your help. I am so excited that it may be possible!

Also, do I need to have the script written for every variable separately? or is there a way to have a “function” defined in the external HTML extension and run the option with the action for the specific text box. I am just hoping that there is a more efficient way to do this, because I may have quite a few variables and input boxes in the module.

Attachments:
  1. Mod2_3.zip