Simulate TAB key with Javascript, and scoring percentage not correct

I’ve spend days trying to solve these two issues.
On slide 7 I’d like to auto tab, or set focus when the user types the correct answer. I’ve marked the line in the code in the OnLoad event with the comment “// The next line is problematic”
I’ve tried:

  • document.getElementById(q2aTEB).focus();
  • document.dispatchEvent(new KeyboardEvent(‘keydown’, { key: ‘Tab’ }));
  • prez.object(q2aTEB).focus();
    None of which worked.

2nd, after the user takes the quiz, the report slide shows 10 out of 10 correct but only reports 43% correct.
By the way, the answers to the blanks for testing are:
protocol
protocol suite
tcp/ip
ip
hundreds
address
0 255
router

I’m just learning Javascript and haven’t yet mastered reporting, but I’ve spent many hours trying to fix these on my own, not wanting to tax the help system.

System: Windows 11 (23H2)
Purchased Version: ActivePresenter 9.1.5
Purchase Date: 2023-11-22
Subnetting.approj (1.5 MB)

Hi,

Your script isn’t working because the object API in ActivePresenter lacks the focus function.
To resolve this, update prez.object("q2aTEB").focus(); to prez.object("q2aTEB").textNode.focus(); and make the same adjustment for other text entries.

Regards,

@rzjunction - it looks to me like some of your text is also marked as graded rather than just your text entry boxes.
A score of 43 percent would indicate that there are 23 total points to be earned.
So you may have 13 objects on the screen to adjust.

Hope that helps.

Yes, you’re a genius! Thank you. That’s hard to catch.

Any idea about the auto-tab by Javascript on correct answer?

1 Like

Thank you so much Hang. I didn’t see your response before I responded to Greg, but this is incredibly helpful.

1 Like