Forum Discussion
- GriffingriffindCommunity Member
Bumping this thread to add another reason for disabling text entry fields:
When reviewing a quiz question, a user can still tab through the focus order and change their answer, even with an object blocking the fields. Then when they return to the results slide it will mark that question as correct. - NedimCommunity Member
You can disable a text entry field at any time with just a few lines of JavaScript. Share your scenario or setup, and we'll make it work if feasible.
- GriffingriffindCommunity Member
I can't share the specific file since it contains proprietary information but would you be able to share the lines of Javascript that are needed?
- RickBarrettCommunity Member
Thank you, Nadim! Works like a charm.
- NedimCommunity Member
No problem, Rick. Glad it worked.
- NedimCommunity Member
To target a unique ID of an input element, you might use something like
id="acc-5nkaJ2cbCf9"
. To find and reference this ID in your script, you would first need to get it from the developer console and then update your script with a line such asdocument.getElementById('acc-5nkaJ2cbCf9')
. If you need to use the same script on a different slide or with a different TEF, you would need to repeat this process to update the code. Now, imagine you have multiple TEFs that you want to enable or disable based on certain actions. This approach would not be reusable without constantly updating the code. Getting all inputs at the same time and then isolating the specific one you need by its index number proves to be the easiest method that works. - NedimCommunity Member
We can also make this more efficient by creating global functions to avoid repeating code, and run this code only when the timeline starts on this slide.
Now we can call a function to disable the TEF under certain conditions:
window.disableInput(0); // 0,1,2,3...
Or call a function to enable the TEF under different conditions or when something else happens: window.enableInput(0); // 0,1,2,3...