如何将用户输入 HTML 发送到 R 函数

How to send user input HTML to R function

我有一些带有按钮(“btn”)的闪亮应用程序,当我点击它时我得到了 shintalert:

observeEvent(input[["btn"]], {
    shinyalert(
      title = "some title",
      type = "info",
      showConfirmButton = FALSE,   
      html = TRUE,
      text = div(HTML(
             "<form>                                                 
             <textarea id='my_txt' name='my_txt' rows='8' cols='100'></textarea>
             <input type='text' id='my_txt2' name='my_txt2'  style='display: block;'/>
             <button onclick= ",SOME_R_FUNCTION(my_txt,my_txt2 ),">click me</button>
             </form>"
             ))
             )})
     

在表单中我有 2 个文本框和一个按钮。 当用户单击按钮时,我想将两个文本框的用户输入发送到我的 R 函数 - SOME_R_FUNCTION。 我找不到我该怎么做。

library(shiny)
library(shinyalert)

ui <- basicPage(
  useShinyalert(),
  actionButton("btn", "Click me")
)

server <- function(input, output){
  observeEvent(input[["btn"]], {
    shinyalert(
      title = "some title",
      type = "info",
      showConfirmButton = FALSE,   
      html = TRUE,
      text = "<div>
          <textarea id='my_txt' name='my_txt' rows='8' cols='100'></textarea>
          <input type='text' id='my_txt2' name='my_txt2' style='display: block;'/>
          <button>click me</button>
        </div>",
      callbackJS = "function(){Shiny.setInputValue('userInputs', [$('#my_txt').val(), $('#my_txt2').val()]);}"
    )
  })
  
  observeEvent(input[["userInputs"]], {
    # apply your R function here
    print(input[["userInputs"]])
  })
  
}

shinyApp(ui, server)