Reset checkbox

I have a scenario where a user has the ability to select a checkbox, however they are to get immediate feedback that it is the wrong answer and the checkbox should then be unchecked. I'm trying to use a free form checkbox for this, rather than a question and I cannot figure out how to get the checkbox to uncheck using an On Select/Change action. I've tried various "standard" JavaScript solutions, including the "click", the "checked" attribute change so far to no avail using RunJS. I even tried using JS that changed the variable itself.


Other than making it a "question" and forcing a reset of the question if they choose that particular checkbox, any thoughts on a way to force it to be unchecked after a user selects it?


Edit: It doesn't look like I can find a "reset question" option either, so still stumped how I would be able to do this at all.


Cheers,

Jason

Discussion (5)

Instead of unchecking, you could use the "Hide" action. Example they check wrong option, and you provide feedback in text box " I am sorry, that answer is incorrect. Please Try again" then hide that answer after a short delay.

Unfortunately, that's not an option, as the option still needs to be visible - it's not a quiz question, really. This is a software simulation where there are multiple options to select, but for this demo, one of them is incorrect. I'm being very particular and want it to "uncheck" after giving them the feedback that it shouldn't be selected in this scenario.

If you need to turn it off, you can make an action Run JavaScript that has this code:

document.getElementById("%HTMLNAME%"+"id").checked = false;


I used the console to find the name of the actual checkbox and it is the name of the Lectora Object with "id" at the end. If you use the %HTMLNAME% it will pass its name into the JS without needing to hard code it. Hope that helps!

I must have been mis-coding it the first few times I tried it, thanks! It's been too long since I hand coded JS :) Thanks for the help getting this one straightened out!

Getting the right handle in JS is so important. I have banged my head on the wall a few times trying to get things to work right in Lectora with JS. Glad the code worked for you