Hello I want to modify input$submit value, the variable "submit" is created by: actionButton("submit", "submit"), I notice the original input$submit value is
[1] 0
attr(,"class")
[1] "shinyActionButtonValue" "integer"
Every time, I click "submit "button, the input$submit[[1]] value will increase by 1. I want to reset it to 0; I follow chatgpt answer. It does not work. How can I reset the value to its original value?
HI @yu.cai.tch. Like you, I thought shinyjs would offer a solution, but according to the documentation for the reset() function, action buttons are not supported. One way I've handled this before is by introducing a reactiveVal that serves as the button counter (input_button_value in example below). Every time the submit button is clicked, the reactiveVal increases by 1. When the reset button is clicked, the reactiveVal is set to 0. Then, any place in the app I would want to use the counter value of the submit button, I would refer to this reactiveVal.
I reworked the sample app you provided to illustrate this concept below.
Thank you so much, Scott. The purpose that I want to reset input$submit to 0 is that I want to reset my UI. I do not know how to reset my UI. After I fill the parameters in UI, I want to reset it to the original state with empty values. Currently, I have to turn off it and relaunch it to achieve this purpose.
Hello nirgrahamuk, Thank you for your information. Great to know and take some time to learn these codes. It looks like that input$mybutton value can not change,. In the above code, through the difference "input[[inputId]] - internal_count()", it achieved that it looks that the value is reset. In fact, input$mybutton has never change. It is a clever way to bypass this issue.
I used DT library to fill in the input values in DT table input. I want to use a reset button to reset its value to empty after I complete the task. It looks that my thinking to reset input$mybutton is difficult. I also find to reset DT table is quite difficult.