I want to set a condition on the conditionalPanel such that as long as selectInput contains 1, the conditionalPanel will show.
I am not familiar with JavaScript, can someone help?
library(shiny)
library(shinydashboard)
ui <- function() {
dashboardPage(dashboardHeader(),
dashboardSidebar(
selectInput(inputId = "month", label = "Month", choices = 1:12, multiple = TRUE)
),
dashboardBody(
conditionalPanel(condition = "input.month == '1'", h1("success"))
),
skin = "blue")
}
server <- function(input, output, session) {
}
shinyApp(ui, server)
Given a JavaScript array arr, the index of element x in arr is given by arr.indexOf(x). If x does not belong to arr, then arr.indexOf(x) returns -1.
So the condition you're looking for is
condition = "input.month.indexOf('1') > -1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With