log the only final status of the radio button

PennController for IBEX Forums Support log the only final status of the radio button

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6340
    pchen
    Participant

    Hi Jeremy,

    I need to present a list of names on one page to the participants and they’re told to select some of the names (with radio buttons). I want to give them the choice to unselect if they need to.
    However, I noticed once an item is selected, regardless whether it is unselected later, the result would always record that item being selected.

    Is there a way to only log the final status of the radio button?
    Below is the relevant script, most of which was from your earlier solutions to other posts here.
    Another thing is how I could log the actual item (names). Currently, the result only logs the scale name with order (i.e., know1, know2). This is less important because I present items in a fixed order.

    Thank you,
    Peiyao

    question = (name,text) => [
        newText("Question-"+name, text)
        ,
        newScale("know", "do you know the name?")
            .log("last")
            .before(getText("Question-"+name) )
            .size("auto")
            .print()
        ,
        newCanvas("empty canvas", 1, 10)
             .print()
    ]
    newTrial("names",
       ...Authornames.map((v,i) => question(i,v))
        ,
        
        newFunction( () => {
         $(".PennController-Scale input[type='radio']").click(function(){ 
            $(this).attr("toggle", $(this).attr("toggle") != "true" );
            if ($(this).attr("toggle")=="false") $(this).removeAttr("checked");
             })
        }).call().log()
        ,
        newCanvas("empty canvas", 1, 30)
             .print()    
        , 
        newButton("done", "Done")
            .print()
            .settings.css("font-size", "24")
            .center()
            .wait()
    
    )
    #6342
    Jeremy
    Keymaster

    Hi Peiyao,

    You’d probably be better off using a good old HTML checkbox input, which comes with the on/off switch behavior you’re looking to implement by default:

    question = (name,text) => [
        newText("Question-"+name, text)
        ,
        newHtml("know-"+name, "<input type='checkbox' id='know-"+name+"' name='know-"+name+"'>"+
                              "<label for='know-"+name+"'>I know this name</label>")
            .log()
            .before(getText("Question-"+name) )
            .size("auto")
            .print()
        ,
        newCanvas("empty canvas", 1, 10)
             .print()
    ]
    
    newTrial("names",
        ...Authornames.map((v,i) => question(i,v))
        ,
        newCanvas("empty canvas", 1, 30)
             .print()    
        , 
        newButton("done", "Done")
            .print()
            .settings.css("font-size", "24")
            .center()
            .wait()
    )

    Jeremy

    #6343
    pchen
    Participant

    That works! Thanks!

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