Forum Discussion

SumitBedi-719eb's avatar
SumitBedi-719eb
Community Member
7 years ago

Count the characters of a textbox in Storyline 3/ 360

This simple tutorial teaches you how to get the number of characters in storyline textboxes. You can use the functionality to set limits to the short/long answers.

Watch it here: 

 

 

6 Replies

  • PunamParab's avatar
    PunamParab
    Community Member

    Thanks for sharing this, Sumit. Perhaps, you could give the Javascript code as a download. This way there would be no need to type it all over again.

    • SumitBedi-719eb's avatar
      SumitBedi-719eb
      Community Member
      let player = GetPlayer()
      let text1 = player.GetVar('textEntry').length
      player.SetVar('count', text1)

      //You can replace 'count' and 'textEntry' with your defined variables :)
  • Is there a way to have the count variable automatically +1 as the user types? So the count variable adjusts in real time?

  • That's what I need to achieve, Amanda! Please do share if you've found a way to do it.

    I'm also hoping to find a code for word count instead of character count.  

  • I have been trying to achieve something similar. It'd really be great if these fields just updated automatically, or if, at the very least, you could access the Element ID of the text input fields so you can make the Javascript easier.

    Chris Hodgson (as usual) does some pretty incredible stuff in this video. One of the things he does, however, is use jQuery to constantly monitor how many characters the user is typing. 

    Unfortunately, it takes getting into the published code and adding a single line of code to allow the course to access the jQuery library. It's also still a bit over my head in terms of what Chris is doing. So, trying to reverse-engineer his code to do what I need it to do, but I'll get there I'm sure.

    Anyway, I hope this helps you all! 

    His video is here!