Here is a simple Shiny application
library(shiny)
ui <- fluidPage(
column(9, style = "padding:0px 10px 0px 0px;",
conditionalPanel(
condition = "input.fusrctmax == 0",
selectInput("ctmax", "Maximum contact time :",
choices = c("500","1000","2000","5000","10000"),
selected = "10000")
),
conditionalPanel(
condition = "input.fusrctmax == 1",
numericInput("usrctmax", "Maximum contact time", value = 10000)
)
),
checkboxInput("fusrctmax", "User", FALSE),
verbatimTextOutput("debug")
)
server <- function(input, output, session) {
observeEvent(input$fusrctmax, {
if (input$fusrctmax)
updateNumericInput(session, "usrctmax", value = as.numeric(isolate(input$ctmax)))
else
updateSelectInput(session, "ctmax", selected = isolate(input$usrctmax))
})
output$debug <- renderText({
paste("fusrctmax:", input$fusrctmax,
"| ctmax:", input$ctmax,
"| usrctmax:", input$usrctmax)
})
}
shinyApp(ui, server)
When the checkbox is checked, the numerical input does not allows me to change values !?!
Why ?
Thanks
Daniel
Here is a simple Shiny application
library(shiny)
ui <- fluidPage(
column(9, style = "padding:0px 10px 0px 0px;",
conditionalPanel(
condition = "input.fusrctmax == 0",
selectInput("ctmax", "Maximum contact time :",
choices = c("500","1000","2000","5000","10000"),
selected = "10000")
),
conditionalPanel(
condition = "input.fusrctmax == 1",
numericInput("usrctmax", "Maximum contact time", value = 10000)
)
),
checkboxInput("fusrctmax", "User", FALSE),
verbatimTextOutput("debug")
)
server <- function(input, output, session) {
observeEvent(input$fusrctmax, {
if (input$fusrctmax)
updateNumericInput(session, "usrctmax", value = as.numeric(isolate(input$ctmax)))
else
updateSelectInput(session, "ctmax", selected = isolate(input$usrctmax))
})
output$debug <- renderText({
paste("fusrctmax:", input$fusrctmax,
"| ctmax:", input$ctmax,
"| usrctmax:", input$usrctmax)
})
}
shinyApp(ui, server)
When the checkbox is checked, the numerical input does not allows me to change values !?!
Why ?
Thanks
Daniel