Skip to content

Instantly share code, notes, and snippets.

@jldohmann
Created February 18, 2020 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jldohmann/73cb175019eb4193943b1ee601ad04b3 to your computer and use it in GitHub Desktop.
Save jldohmann/73cb175019eb4193943b1ee601ad04b3 to your computer and use it in GitHub Desktop.
A template for toggling different input fields based on user selection
DynamicModule[{toggle, input = 1},
toggle[a_, b_] := PaneSelector[{a, b}, Dynamic@input];
Grid[{
{
"First Row",
RadioButtonBar[Dynamic@input,
{
1 -> "Item A",
2 -> "Item B"
}
], SpanFromLeft
},
{
toggle["Second Row; Item A", "Second Row; Item B"],
toggle[InputField[Dynamic@input, String],
InputField[Dynamic@input, String]],
toggle[Button["Clear", input = ""], Button["Clear", input = ""]]
}
}, Alignment -> Left]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment