How can I move from one tab to another using actionButton() when then name of the tab is dynamic in a shiny app?
library(shiny)
ui <- fluidPage(
tabsetPanel(
id="inTabset",
tabPanel("Tab 1",textInput("name","Name"),actionButton("switch_tab", "Go to the third tab")
),
tabPanel("Tab 2", "there!"),
tabPanel(textOutput("TAB3")))
)
server <- function(input, output, session) {
observeEvent(input$switch_tab, {
updateTabsetPanel(session, "inTabset",selected = "Tab 3")
})
output$TAB3<-renderText({
if(input$name==""){
"Tab 3"
}
else{
paste(input$name)
}
})
}
shinyApp(ui = ui, server = server)