Recording participant email address
Note: Due to a strange issue with the forum this post failed to render. I [Sebastiaan] therefore posted it as a comment below.
Note: Due to a strange issue with the forum this post failed to render. I [Sebastiaan] therefore posted it as a comment below.
Comments
Hello!
I am designing an online experiment and I need to record the participants email address in order to include them in a draw for winning a prize.
I tried to modify an already existing loop with an inline java script that was designed to record participant’s student ID :
https://forum.cogsci.nl/uploads/270/FHI28IF56H34.png
https://forum.cogsci.nl/uploads/626/97CWIVZOW7KM.png
https://forum.cogsci.nl/uploads/649/5EU03FR3S0J3.pngI changed the script so in the ' if statement' the 'vars.response' matrix included other keys (letters, dot, etc.), but it doesn’t seem to work and it only records numbers in the student_number variable (not sure but probably because strings can’t be stored in a variable)
Anyway I was wondering if there was a way for me to be able to record the participants email address (they will need to see what they are typing and also be able to erase mistakes) ?
Thank you,
Sana
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @Sana_2 ,
(As you probably noticed, something weird happened with this post. I fixed it by copy-pasting your question in my previous comment.)
I changed the script so in the ' if statement' the 'vars.response' matrix included other keys (letters, dot, etc.), but it doesn’t seem to work and it only records numbers in the student_number variable (not sure but probably because strings can’t be stored in a variable)
That would indeed be the way to go. I suspect that there was simply something wrong with the if statement. Could you post the code here?
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hello Sebastiaan,
Thank you for your response!
Yeah it seems so.... perhaps cause I accidentally posted it twice and tried to erase it but couldn't (not sure). Anyway thanks for responding here!
Here is the code:
console.log(vars.response) if (vars.response in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","z","y","@",".","-","_","space","slash"]) { vars.student_number += vars.response.toString() } else if (vars.response === 'backspace') { vars.student_number = vars.student_number.toString().slice(0, vars.student_number.toString().length - 1) }Just to clarify when I check the student_number variable afterwards only the numerical values are recorded and the other keyboard responses are just empty cells (this also results to only seeing the numerical keyboard responses on screen when typing in the email address)
Thank you very much for assisting on this !
Sana
Hi @Sana_2 ,
I suspect that the issue is simply that the keys have slightly different names from the ones that you're assuming in the
ifstatement. After every key press,var.responseis printed out to the browser console, so you can go there and check what the keys are actually called and then modify the key names in your script accordingly.Also: right now you're simply appending the key names to
var.response, and therefore "two words" becomes "twospacewords", if you see what I mean. So you'll probably have to use a slightly more complex if statement that checks the key name, and then appends the correct character in case that's not equal to the key name.Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thank you for bringing the "space" issue into my attention I tried solving it by adding an extra condition
I checked the browser console and except for a few key names like( @, .,/,-,_) the rest of the keys seemed to have similar names. Even when I removed the questionable keys the problem still remained. Also, when I run the script in the traditional (non-browser) way in OpenSesame I still have the same issue.
Thank you,
Sana
I attached a simple demonstration experiment that accepts email addresses. It's a modified version of the multiple-character input script. Actually the only thing that needed to be changed is the list of allowed keys in the
keyboard_responseitem!Check out SigmundAI.eu for our OpenSesame AI assistant!
Oh wow! That was a lot simpler than the things I tried...
Thank you very much for your help!