Moving Submit button function to Action button

This is my first app, I'm trying to modify the code from a submitbutton to an actionbutton as recommended and allow further functionality. Ive tried numerous examples and I can't replicate the results that I get when using the submitbutton. The section of code commented out with eventreactive and using the action button is not working but the heldinput and output$Held section below works fine with the submit button. These sections pass some input$etc as arguments to a external function. Any help greatly appreciated

ui<-fluidPage(
  tabsetPanel(
    tabPanel ("Todays Buy Recommendations",tableOutput(outputId="Buy_List")),
    tabPanel ("Currently in an uptrend",tableOutput(outputId="Trend")),
    tabPanel ("Charts",
              
              plotOutput("chart",width=1350,height=600),
              hr(),
              fluidRow(
                column(2,
                       textInput(inputId="TickerName","Select Ticker",value="BHP.AX")
                       
                ), 
                
                column(1,
                       submitButton("Retrieve Chart")
                ) 
              )
    ),
    tabPanel("Current Portfolio",
             sidebarLayout(
               sidebarPanel(
                 
                 dateInput(inputId="Date","Transaction Date",Sys.Date()),
                 numericInput(inputId="Number", "Number Traded",0),
                 textInput(inputId="Ticker","Enter a ASX followed by .AX",value="ÄSX.AX"),
                 selectInput(inputId="BSD","Buy Sell or Delete ",c("Buy","Sell","Delete","NULL"),selected= "NULL"),
                 textInput(inputId="Price","Price",value="0.00"),
                 submitButton("Submit Transaction")
                 # actionButton("do", "Submit ")
               ),
               mainPanel(tableOutput("Held"))
               
             ))
    
  ))

server<-function(input,output){

  
  #This section not working with action button
#  heldInput<- eventReactive(input$do, {
#    HoldAdjust(input$Date, input$Number, input$Ticker, input$BSD, input$Price)
#  },ignoreNULL = FALSE
  )
#  
#  output$Held <- renderTable({
#    heldInput()
#  })
  
  #This section works fine with submit button
  heldInput<-reactive(HoldAdjust(input$Date, input$Number, input$Ticker, input$BSD, input$Price))
  output$Held <-renderTable(heldInput(),striped=TRUE,digits=3)
  
  RecBuy$date <- format(RecBuy$date,'%Y-%m-%d')
  output$Buy_List <-renderTable(RecBuy,striped=TRUE,digits=3)
 
  TrendCF$date <- format(TrendCF$date,'%Y-%m-%d')
  output$Trend<-renderTable(TrendCF,striped=TRUE,digits=3)
  
  
  dataInput <-reactive({input$TickerName})
  output$chart<-renderPlot({chart(dataInput())})
  
} 

shinyApp(ui=ui,server=server)

a single submit button will effect an entire app.
If you had two submit buttons, and change just one to an actionbutton, the remaining submit button will constrain its behaviour. I believe this is documented :

In essence, the presence of a submit button stops all inputs from sending their values automatically to the server. This means, for instance, that if there are two submit buttons in the same app, clicking either one will cause all inputs in the app to send their values to the server. This is probably not what you'd want, which is why submit button are unwieldy for all but the simplest apps.

Therefore I recommend you replace both submit buttons, and then see where you are.

Thanks for the reply.

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.