I need to show different dropdown/selectinput for different tabs.
Ex. If tab one is selected, then show selectinput with a list of values Tim, Bill, Jeff, ... If tab two is selected, then show selectinput with a list of values Cat, Dog, Squirrel, ...
I found the below script online but it does vice-versa (shows/hides tabpanels based on selectinput selection - But I need show/hide selectinput based on tabpanel selection).
runApp(list(
ui = shinyUI(
fluidPage(
sidebarLayout(
sidebarPanel(
selectInput(
inputId = 'selected.indicator',
label = 'Select an option: ',
choices = c('mean', 'median', 'mode')
)
),
mainPanel(
tabsetPanel(
tabPanel("Prevalence / mean", value = 'meanTab', DT::dataTableOutput("prevtab")),
tabPanel("Subgroups comparison", value = 'medianTab', DT::dataTableOutput("comptab")),
id ="tabselected"
)
)
)
)
),
server = function(input, output, session) {
observe({
req(input$selected.indicator)
if (grepl("MEDIAN", toupper(input$selected.indicator), fixed = TRUE)) {
hideTab(inputId = "tabselected", target = 'medianTab')
}
else showTab(inputId = "tabselected", target = 'medianTab')
})
}
))