Forum Discussion

JohnCooper-be3c's avatar
JohnCooper-be3c
Community Member
7 years ago

Input a phone number in a software simulator - Javascript required

Hi. I don't know if anyone can help. I'm building a simulator of a piece of software for a client who needs people training on the software - and doesn't want them practicing on the live system!. We've done a few of these and Storyline works really well for this. I grab a screen, overlay it with text input boxes and then pretend to be the software.

I have one minor problem. I want to input a telephone number. The software I'm simulating doesn't parse the number it just only accepts digits. So, if I create a number variable and use a numeric entry box, this works fine. BUT when I run the simulator the entry box shows the default value of the variable i.e. '0' - the software doesn't do that. So, I'm looking for a way to get rid of that zero in the screen display.

I figure if I use a JavaScript trigger I can read the input character by character rejecting anything that's not a digit and then set a Storyline Variable (doesn't have to be a numeric variable - a text variable would work better) at the end. My limited JavaScript isn't up to that though! Any assistance would be greatly appreciated.

  • JoeDey's avatar
    JoeDey
    Community Member

    Can’t you just use a text entry box?

    • DiarmaidCollins's avatar
      DiarmaidCollins
      Community Member

      Hi Phil. That's absolutely fantastic!

      And EXACTLY what I am looking for. (and struggling with).

      Is there any chance you could share the Storyline file or explain how you get the individual number buttons to simply "join" with the previous inputted numbers? I cannot wrap my head around this - I can only apply the arithmetic functions... oh... do you just treat the input variable as a text and simply program the number buttons to add text to the variable string?

      It's a Sunday night, my brain hurts from working on a super complicated module all weekend and this is like finding buried treasure... or, hopefully a magic genie.

       

  • Hi Joe

    Thanks for the question. The problem with a text entry box is that it accepts alpha characters. The software I'm simulating just ignores non-numerics - which is what the numeric entry box will do just fine. It's just the display of the '0' default value I would like to get rid of.

    Hi Phil

    I love the sweet shop challenge - I may use that idea at some point in a quiz. But obviously what I'm trying to do here is mimic as closely as I can the software I'm simulating.

    I tried blanking out the field with a mask that disappears when you click it - which got rid of the '0' display  on the data entry screen but as soon as the mask disappears the dratted '0' appears. To be honest it's not a major problem and I may just have to accept the simulator is 'close enough' to the software it is pretending to be. I might experiment with changing states - there are some amazing, and unexpected, things you can do with states - this is how I overcame the 'drop-down' menu fields in the simulator.

    Thanks again.

  • I dont have the file anymore. On this one all I did was add the number and multiply by 10, Now I do it with a text entry and use javascript to do the calculation, as there seems to be a math error in SL at the moment