Problems with actionButton.

As you can see below, I tried to write a code and it works quiet nicely. I tried to implement actionButtons to navigate between pages. All the actionButton works but not in the last page. I want it to navigate back to previous page and it doesnt do anything. I tried debugging a lot but couldnt find any problem. Maybe a new pair of eyes can find the problem in my code.


library(shiny)
library(shinythemes)

ui <- fluidPage(theme = shinytheme("sandstone"),
        titlePanel("Automatic Evaluation"),
                navbarPage("", id = "inTabset",
                           
                           tabPanel(value = "panel0", icon("home"),
                           fluidRow(column(width=12, height=12,
                                      br(),
                                      p("Hello. This para is for description", strong("and also this"), 
                                                                        style="text-align:justify;
                                                                               color:black;
                                                                               background-color:lavender;
                                                                               padding:12px;
                                                                               border-radius:100px"),
                                      actionButton('jumpToP1', 'Proceed')
                                    ))),
                           
                           tabPanel(value = "panel1", title = "Process Selection",
                                      p("Process Selection"),
                                    
                                      br(),
                                      br(),
                              
                                      actionButton('jumpToP0', 'BACK'),
                                      actionButton('jumpToP2', 'NEXT')),
                          
                           tabPanel(value = "panel2", title = "Modifying and Saving", 
                                      p("Modifying and Saving"),
                                    
                                      br(),
                                      br(),
                                    
                                      actionButton('jumpToP1', 'BACK'))
                                      ))

server <- function(input, output, session) {
  observeEvent(input$jumpToP0, {
    updateTabsetPanel(session, "inTabset",
                      selected = "panel0")
  })
  
  observeEvent(input$jumpToP1, {
    updateTabsetPanel(session, "inTabset",
                      selected = "panel1")
  })
  
  observeEvent(input$jumpToP2, {
    updateTabsetPanel(session, "inTabset",
                      selected = "panel2")
  })
  
}

shinyApp(ui, server)

Hey there, you can’t have multiple input widgets with the same id. If you rename one “ jumpToP1” and adjust code accordingly in the server portion, you should be good

Hello, thank you so much for your help. I really appreciate it.

Yes, It worked perfectly. I changed the ID in last actionButton and added one more observeEvent with that ID to the page I wanted. Another quick question, is there anyway to move these actionButtons to left and right bottom of the page?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.