Change the value of a radio group buttons input on the client
Change the value of a radio group buttons input on the client
updateRadioGroupButtons( session, inputId, label = NULL, choices = NULL, selected = NULL, status = "default", size = "normal", checkIcon = list(), choiceNames = NULL, choiceValues = NULL, disabled = FALSE, disabledChoices = NULL )
session |
The session object passed to function given to shinyServer. |
inputId |
The id of the input object. |
label |
The label to set. |
choices |
The new choices for the input. |
selected |
The value selected. |
status |
Status, only used if choices is not NULL. |
size |
Size, only used if choices is not NULL. |
checkIcon |
Icon, only used if choices is not NULL. |
choiceNames, choiceValues |
List of names and values, an alternative to choices. |
disabled |
Logical, disable or enable buttons,
if |
disabledChoices |
Vector of specific choices to disable. |
if (interactive()) { library("shiny") library("shinyWidgets") ui <- fluidPage( radioGroupButtons( inputId = "somevalue", choices = c("A", "B", "C"), label = "My label" ), verbatimTextOutput(outputId = "res"), actionButton(inputId = "updatechoices", label = "Random choices"), pickerInput( inputId = "updateselected", label = "Update selected:", choices = c("A", "B", "C"), multiple = FALSE ), textInput(inputId = "updatelabel", label = "Update label") ) server <- function(input, output, session) { output$res <- renderPrint({ input$somevalue }) observeEvent(input$updatechoices, { newchoices <- sample(letters, sample(2:6)) updateRadioGroupButtons( session = session, inputId = "somevalue", choices = newchoices ) updatePickerInput( session = session, inputId = "updateselected", choices = newchoices ) }) observeEvent(input$updateselected, { updateRadioGroupButtons( session = session, inputId = "somevalue", selected = input$updateselected ) }, ignoreNULL = TRUE, ignoreInit = TRUE) observeEvent(input$updatelabel, { updateRadioGroupButtons( session = session, inputId = "somevalue", label = input$updatelabel ) }, ignoreInit = TRUE) } shinyApp(ui = ui, server = server) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.