| Reference | Downloads | Github

Getting the "form component" to record sex and age

Hi, I’m having to use a form component in builder to collect sex (male/female/prefer not to say) and age (18-99) information as I’m running an experiment online and am not using paper copy forms.

I can’t seem to get it to work though. The question type can only be rating, slider or radio?

All I want is to be able to tick a box (or type an answer) for the sex question, and a typed answer for the age question. Does anyone know whether that’s possible?
Thanks in advance!

At the moment you need a code block for a typed answer. Have a look at the attached template.

template.psyexp (31.0 KB)

Best wishes,



Wow, that’s perfect - Just what I needed! Thank you so much!

1 Like

Hey again, although this seems to work really well offline, online the age question does not work (it automatically fills in 99??). I don’t know enough Java to fix it, any ideas? Thanks for all your help so far, apart from this one niggle the experiment is now actually working both online and offline…!

Can you delete the 99 to enter an age? It’s probably due to the keys being pressed in a previous routine. There might be some way to clear the keyboard buffer but another way would be to reset the recorded response to blank on the 5th frame or something, or only allow a 9 as a second digit.

Hey, No I can’t delete the 99. It’s definitely to do with the keyboard buffer!!! Basically in the age question it will show whatever number I typed in as the participant number!

I tried clearing the keyboard buffer by typing in “getKeys(keyList=None, waitRelease=True, clear=True)” at the start of my age routine but it doesn’t work? (I’m not very good with the code…)

How do I best clear the keyboard buffer?

Thank you very much!

Just to let any readers know what I have resolved this by typing in “event.clearEvents()” at the start of the routine, which clears the keyboard buffer.

Wakefield - Many thanks for suggesting I clear the keyboard buffer and for all your other expert advice over the last few days. I now have a fully functioning online experiment thanks to your help!

1 Like