Forum Discussion
ndincerdino
3 years agoCommunity Member
Word Count in Text Entry
Hi, I am creating a writing task for my students. I need to add wordcount sign on the page. How can I do it? My students should see the number of words they have written simulateneously.
Many than...
Nedim
3 years agoCommunity Member
Hi Riona,
You may wanna use this code:
const TE = document.querySelector('.acc-textinput');
const player = GetPlayer();
TE.addEventListener('keyup', () => {
TE.blur();
TE.focus();
let charCount = TE.value.length;
player.SetVar("charCount", charCount);
});
Make sure you first create a number variable "charCount" in Storyline. It can be named anything you want but a variable in the code above (bolded) must match a variable created in SL. This code has to be placed in Execute Javascript trigger when the timeline starts.