Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
Trying to incorporate JS into shiny

I am trying to incorporate JS into Shiny that is without writing anything to server. Here is the code

library(shiny)

ui <- fluidPage(
  tags$head(HTML('<p id="res">Value</p>'),
  tags$script("document.getElementById('res').innerHTMl=x")),
  textInput("x", label = "Text")
)

server <- function(input, output) {
}

shinyApp(ui, server)

So basically, whatever we write inside the text box, the "Value" should get changed. Can anyone help me?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This would do it.

  • Try not to put actual content like text inside tags$head except meta, link, CSS or script.
library(shiny)

ui <- fluidPage(
    HTML('<p id="res">Value</p>'),
    textInput("x", label = "Text"),
    tags$script("$('#x').on('input', function(){$('#res').text($(this).val());});")
)

server <- function(input, output) {}

shinyApp(ui, server)
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda