Give feedback based on all buttons previously pressed #2899
jaimielee97
started this conversation in
General
Replies: 1 comment 4 replies
-
Shouldn't you be able to work that out from the Perhaps a use case would be: var currentSquare = data.response
if (clickedSquares.includes(currentSquare)) {
//this square has been clicked
} else {
//this square has not been clicked
} Although this means you need to adjust your code so it takes into account the fact that not every button click is 'valid', i.e. you can have 10 trials (so Another way to go about this could be to disabled buttons once they are clicked, e.g. on_load: function(){
for (let square of clickedSquare) {
document.querySelector('some-way-to-target-your-button-by-their-data.response').disabled = true
}
} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I'm attempting to code an experiment where there is a 12x12 grid of buttons, and participants receive feedback based on which buttons/squares they choose to explore. When they click a square for the first time, they discover if it is either a normal square, which results in a small loss, or a rare critical square, which will result in a large gain. However, if they re-click on a square that has already been clicked in subsequent trials, they will receive 0 points. I am struggling to work out how to code this in a way that remembers where participants have clicked for previous trials.
I've attached the code I have so far below. I have it working so that it registers when a square is a critical square, but can't get it working so it knows if a square is new or has been previously explored. I think it may be including the current trial in the list of clicked squares at the moment, although moving clickedSquares.push(data.response) after the if statements didn't seem to help either. Any help would be greatly appreciated, thank you!
Beta Was this translation helpful? Give feedback.
All reactions