Retrieve the value of <input type='date'> from renderTable

Hi everyone,

I would like to retrieve the value of my <input type='date'> in my Shinyapp.
I can display the value of the field 'i_before' including a <select> input.
Do you have an idea to retrieve and display the value of my input date?

Thanks in advance !

ui <- basicPage(
    tableOutput("My_table")
)

server <- function(input, output, session) {
    My_table = matrix()

    output$My_table <- renderTable({
        event_date <- paste0("<input type='date' id='date_input' min='2018-01-01' max='2018-12-31' >")
        print(input$date_input)
        i_before <- paste0( '<select id="single_select" style="width: 100%;">
                                          <option value="A">O</option>
                                          <option value="B">B</option>
                                          <option value="C">C</option>
                                        </select>')
        print(input$single_select)

        df <- cbind("38KCB",event_date,i_before)
        return(df)
    }, sanitize.text.function = function(x) x
                                   )  }

shinyApp(ui = ui, server = server,options = list(launch.browser = TRUE))```

You can do this;
get a text representation of the way shiny builds its typical date input; load the dependencies into the ui.

library(shiny)
ui <- basicPage(
  tableOutput("My_table"),
  shiny:::datePickerDependency()
)

server <- function(input, output, session) {

  My_table = matrix()
  
  output$My_table <- renderTable({
    event_date <- dateInput(inputId = "date_input",
                            label = character(0), 
                            min='2018-01-01' ,
                            max='2018-12-31' ) |> as.character()
    print(input$date_input)
    i_before <- paste0( '<select id="single_select" style="width: 100%;">
                                          <option value="A">O</option>
                                          <option value="B">B</option>
                                          <option value="C">C</option>
                                        </select>')
    print(input$single_select)
    
    df <- cbind("38KCB",event_date,i_before)
    return(df)
  }, sanitize.text.function = function(x) x
  )  }

shinyApp(ui = ui, server = server,options = list(launch.browser = TRUE))

This topic was automatically closed 54 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.