PennController for IBEX › Forums › Support › Output Text based on Selection in Dropdown Menu › Reply To: Output Text based on Selection in Dropdown Menu
Hi Jeremy,
I have a similar request. I have a dropdown menu asking if participants were born in the US (yes/no). If “no” is selected, I would like a further question (in which country they were born) + text input box to appear, as well as the question of when they moved there (Month dropdown and Year Text Input). Currently there is an additional page for these two questions which I would like to get rid of.
These are currently the bits of code:
newText(“borninus”,”Were you born in the United States?”)
,
newDropDown(“borninus”,”select”)
.settings.add(“yes”,”no”)
.size(120,25)
.settings.log()
,
newCanvas(“borninuscanvas”,700,80)
.settings.add(0,0,getText(“borninus”))
.settings.add(300,0,getDropDown(“borninus”))
.center()
.print()
,
newButton(“next”,”Next”)
.center()
.print()
.wait()
)
newTrial(“pagethree-birthplace”,
newText(“skip”,”If you were born in the United States, you may skip this page by clicking \”Next\”.”)
.center()
.print()
,
newText(“countryofbirth”,”In which country were you born?”)
,
newTextInput(“countryofbirth”,)
.log()
.size(300,25)
,
newCanvas(“countryofbirthcanvas”, 700, 120)
.settings.add(0,50, getText(“countryofbirth”))
.settings.add(300,50, getTextInput(“countryofbirth”))
.center()
.print()
,
newText(“movedtous”, “When did you move to the United States?”)
,
newText(“monthmovedtous”, “Month”)
,
newText(“yearmovedtous”, “Year”)
,
newDropDown(“monthmovedtous”,”select”)
.settings.add(“January”,”February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”)
.size(100,25)
.settings.log()
,
newTextInput(“yearmovedtous”,)
.log()
.size(80,25)
,
newCanvas(“movedtouscanvas”, 700, 100)
.settings.add(0,40, getText(“movedtous”))
.settings.add(300,20, getText(“monthmovedtous”))
.settings.add(420,20, getText(“yearmovedtous”))
.settings.add(300,40, getDropDown(“monthmovedtous”))
.settings.add(420,40, getTextInput(“yearmovedtous”))
.center()
.print()
,
newButton(“next”, “Next”)
.center()
.print()
.wait()
)
I’ve tried all kinds of things inlcuding .success / .failure, .callback and if…else codes, but nothing has worked well so far (probably because I keep overlooking something, but ChatGPT was similarly unhelpful). Could you help me find a way how best to go about this?
Thanks so much and best,
Kathy