have a shiny app where i want to hide or show some elements based on user input. This i tried to do by using
conditionalPanel in shiny. However, it works only after pressing the submit button. I want to hide or show the
textInput element without pressing the submit button. Below is an example what I tried.
UI.R:
library(shiny)
shinyUI(fluidPage(
titlePanel("submitButton example"),
fluidRow(
column(3, wellPanel(
sliderInput("n", "N:", min = 10, max = 1000, value = 200,
step = 10),
checkboxInput("checkbox", label = "Message", value = FALSE),
conditionalPanel(
condition = "input.checkbox == true",
textInput("text", "Text:", "text here")),
submitButton("Submit")
)),
column(6,
plotOutput("plot1", width = 400, height = 300),
verbatimTextOutput("text")
)
)
))
Server.R:shinyServer(function(input, output) {
output$plot1 <- renderPlot({
hist(rnorm(input$n))
})
output$text <- renderText({
paste("Input text is:", input$text)
})
})
I want to show the
textInput as soon as user checks the
checkbox and hide it on uncheck without any dependency on
submit button.