Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

updateSelectInput

Change the value of a select input on the client


Description

Update selecInput widget

Usage

updateSelectInput(
  session,
  inputId,
  label = NULL,
  choices = NULL,
  selected = NULL
)

Arguments

session

The session object passed to function given to shinyServer.

inputId

The id of the input object.

label

The label to set for the input object.

choices

List of values to select from. If elements of the list are named, then that name — rather than the value — is displayed to the user.

selected

The initially selected value (or multiple values if multiple = TRUE). If not specified then defaults to the first value for single-select lists and no values for multiple select lists.

Examples

## Only run examples in interactive R sessions
if (interactive()) {

  ui <- semanticPage(
    p("The checkbox group controls the select input"),
    multiple_checkbox("checkboxes", "Input checkbox",
                      c("Item A", "Item B", "Item C")),
    selectInput("inSelect", "Select input",
                c("Item A", "Item B"))
  )

  server <- function(input, output, session) {
    observe({
      x <- input$checkboxes

      # Can use character(0) to remove all choices
      if (is.null(x))
        x <- character(0)

      # Can also set the label and select items
      updateSelectInput(session, "inSelect",
                        label = paste(input$checkboxes, collapse = ", "),
                        choices = x,
                        selected = tail(x, 1)
      )
    })
  }

  shinyApp(ui, server)
}

shiny.semantic

Semantic UI Support for Shiny

v0.4.2
MIT + file LICENSE
Authors
Filip Stachura [aut], Dominik Krzeminski [cre], Krystian Igras [aut], Adam Forys [aut], Paweł Przytuła [aut], Jakub Chojna [aut], Olga Mierzwa-Sulima [aut], Ashley Baldry [ctb], Jakub Chojna [ctb], Olga Mierzwa-Sulima [ctb], Pedro Manuel Coutinho da Silva [ctb], Paweł Przytuła [ctb], Kamil Żyła [ctb], Rabii Bouhestine [ctb], Appsilon Sp. z o.o. [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.