Radio Button selecting shown Text

179 views
Skip to first unread message

Laru Rau

unread,
Aug 19, 2018, 1:01:55 PM8/19/18
to TiddlyWiki

Hey, I'm relatively new to tiddlywiki and unsure how I can achieve one thing, maybe someone can help me.


I want to have multiple radio buttons in one section and a text section where different text is displayed, depending on which button is selected. This selection should be persistent when closing and reopening my tiddlywiki.


Anyway this can be done? Thanks in advance for your help! :)


(I posted the same on the subreddit but I'm not sure if that place is active, so I'm posting here as well)

Eric Shulman

unread,
Aug 19, 2018, 1:51:24 PM8/19/18
to TiddlyWiki
On Sunday, August 19, 2018 at 10:01:55 AM UTC-7, Laru Rau wrote:

I want to have multiple radio buttons in one section and a text section where different text is displayed, depending on which button is selected. This selection should be persistent when closing and reopening my tiddlywiki. 


give this a try:

<$radio field="section" value="1"> One</$radio>
<$radio field="section" value="2"> Two</$radio>
<$radio field="section" value="3"> Three</$radio>

<$reveal state="!!section" type="match" text="1">
   This is PART ONE
</$reveal>
<$reveal state="!!section" type="match" text="2">
   This is PART TWO
</$reveal>
<$reveal state="!!section" type="match" text="3">
   This is PART THREE
</$reveal>

Hopefully, that should get you started in the right direction... let me know how it goes...

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals 

Laru Rau

unread,
Aug 19, 2018, 3:34:58 PM8/19/18
to TiddlyWiki
Thank you Eric, it's working perfectly! :)

TonyM

unread,
Aug 19, 2018, 9:25:08 PM8/19/18
to TiddlyWiki
Laru,

Inspired by Eric I just turned this into re-usable macros, you can place in a tiddler tagged $:/tags/Macro
In the domain example it returns values already in the domain field of other tiddlers 

\define radio-field(fieldname values-filter)
<$list filter="$values-filter$" variable=value>
   
<$radio field="$fieldname$" value=<<value>> > <<value>></$radio>
</$list>
\end
<<radio-field section "A B C">>

<<radio-field domain "[each[domain]get[domain]sort[]]">>

and here is a select version (less space)
\define select-field(fieldname values-filter)
<$select field="$fieldname$">
<$list filter="$values-filter$">
<option value=<<currentTiddler>>><$view field='title'/></option>
</$list>
</
$select>
\end


<<select-field section "A B C">>


<<select-field domain "[each[domain]get[domain]sort[]]">>

Regards
Tony
Reply all
Reply to author
Forward
0 new messages