PennController for IBEX › Forums › Support › Updating checkbox scale conditionally
- This topic has 2 replies, 2 voices, and was last updated 3 years ago by 
laiamt. 
Viewing 3 posts - 1 through 3 (of 3 total)
	
- 
		AuthorPosts
 - 
		
			
				
October 28, 2022 at 6:44 am #9638
laiamtParticipantHi Jeremy,
I would like to have a trial in which participants select an option in a radio button scale and, depending on what they chose, a different scale appears. So far, this works:
newTrial("location", newText("Where do you live?").print() .cssContainer({"margin":"1em"}), newScale("country", "US", "UK").radio() .labelsPosition("right") .log() .print().wait() .cssContainer({"margin":"1em"}) .test.selected("US").success( newScale("us", 'California', 'New York').radio() .labelsPosition("right") .log() .print().wait() ) .test.selected('UK').success( newScale("uk", 'England', 'Scotland').radio() .labelsPosition("right") .log() .print().wait() ), newButton("go") .print().wait() )However, I would like participants to be able to change their choice in the first scale (if they made a mistake, for example) and that the second scale gets updated accordingly. Is there a way to achieve this?
Thanks,
Laia
Demonstration link: https://farm.pcibex.net/r/IvVKNg/
October 28, 2022 at 4:40 pm #9642
JeremyKeymasterHi Laia,
Place the code you have after the first
waitincallbackinstead:newTrial("location", newText("Where do you live?").print().cssContainer({"margin":"1em"}) , defaultScale.radio().labelsPosition("right").log() , newButton("go") , newScale("us", 'California', 'New York'), newScale("uk", 'England', 'Scotland') , newScale("country", "US", "UK").print().cssContainer({"margin":"1em"}) .callback( getButton("go").remove(), getScale("uk").remove().test.selected().success(self.unselect()), getScale("us").remove().test.selected().success(self.unselect()) , self.test.selected("US") .success( getScale("us").print().wait(),getButton("go").print() ) .failure( getScale("uk").print().wait(),getButton("go").print() ) ) , getButton("go").wait() )Jeremy
October 29, 2022 at 6:13 am #9643
laiamtParticipantWonderful! Thanks!
 - 
		AuthorPosts
 
Viewing 3 posts - 1 through 3 (of 3 total)
	
- You must be logged in to reply to this topic.