Updating checkbox scale conditionally

PennController for IBEX Forums Support Updating checkbox scale conditionally

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9638
    laiamt
    Participant

    Hi 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/

    #9642
    Jeremy
    Keymaster

    Hi Laia,

    Place the code you have after the first wait in callback instead:

    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

    #9643
    laiamt
    Participant

    Wonderful! Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.