PennController for IBEX › Forums › Support › log the only final status of the radio button
- This topic has 2 replies, 2 voices, and was last updated 4 years ago by pchen.
-
AuthorPosts
-
November 10, 2020 at 8:26 pm #6340pchenParticipant
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,
Peiyaoquestion = (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() )
November 11, 2020 at 9:54 am #6342JeremyKeymasterHi 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
November 11, 2020 at 12:28 pm #6343pchenParticipantThat works! Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.