I have a selectinput with multiple = TRUE, I need to disable the selectinput once user select the multiple choices. But the selectinput is disabling once I select the first choice and it is not allowing me to select second choice. I have used following code.
library(shiny)
library(shinyjs)
ui <- fluidPage(
br(),
useShinyjs(),
fluidRow(
column(
width = 6,
selectInput(inputId = "check1", label = "Choose", choices = c("choice A","choice B","choice C"),multiple = T),
verbatimTextOutput(outputId = "res1")
)
)
)
server <- function(input, output, session) {
flag_lifecycle <- reactiveValues(val = "Yes")
output$res1 <- renderPrint({
input$check1
})
observeEvent(input$check1, {
shinyjs::disable("check1")
})
}
shinyApp(ui = ui, server = server)
The output I got
Here, selectinput should be disabled only when multiple choice has been selected.
Any help here is appreciated. Thanks in advance!


