Pass sliderInput from Shiny App to Website

Hey everyone,

I'm working on a Shiny App to implement for a survey in Unipark (similar to Qualtrics etc.).
My app is basically a Slider, where my participants should choose a value.

With Unipark I can implement HTML code, in which I can define a variable in which a value can be stored. However, I cant figure out how to pass my sliderInput data to this variable in the HTML website code.

Alternatively, I found a way to display the value from the Slider to Java

function(input, output, session) {
  # An observer is used to send messages to the client.
  # The message is converted to JSON
  observe({
    session$sendCustomMessage(type = 'testmessage',
      message = list(a = 1, b = 'text',
                     controller = input$controller))
  })
}

fluidPage(
  titlePanel("sendCustomMessage example"),

  fluidRow(
    column(4, wellPanel(
      sliderInput("controller", "Controller:",
        min = 1, max = 20, value = 15),
      
      # This makes web page load the JS file in the HTML head.
      # The call to singleton ensures it's only included once
      # in a page. It's not strictly necessary in this case, but
      # it's good practice.
      singleton(
        tags$head(tags$script(src = "message-handler.js"))
      )
    ))
  )
)

and a Javascript

// This recieves messages of type "testmessage" from the server.
Shiny.addCustomMessageHandler("testmessage",
  function(message) {
    alert(JSON.stringify(message));
  }
);

But how can I save this Java Message on my website?

I tried using RMarkdown to implement the entire html code into my html field, however with a dynamic element the file is not solely .html anymore.

Thanks!

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