Disable a radio button in twine sugarcube2?

Twine Version: Sugarcube 2.37.3

Hello all,

I’m trying to find a way to disable my radiobuttons under certain events but can’t seem to get it to work. I was wondering if there was a way to add a parameter through javascript that would disable the radiobutton option, or if there’s a better approach.

Essentially, I’m putting some stats into my game and want to disable the radiobutton if the stats aren’t high enough. I still want it to display as a greyed out option so players know what is possible.

You can enclose you’re <<radiobutton>> inside an <<if>><</if>>. You might have to put an an extra effort to be sure to have one checked button is it’s important one option being selected.

You can use JQuery to toggle the state of the underlying input element.

<label id="radio-yes"><<radiobutton "$key" autocheck>>Yay!</label>

<<button "Disable 'yes'">>
	<<run $("#radio-yes input").attr('disabled', 'disabled') >>
<</button>>

<<button "Enable 'yes'">>
	<<run $("#radio-yes input").removeAttr('disabled') >>
<</button>>

You can also use this custom macro to easily disable interactive elements.

The macro ended up being perfect for what I needed. Thank you everyone for the answers! And @souppilouliouma I am using if statements as well, so good call.