Multiplue HTML in R Shiny

I have multiple HTML files, and I would like to create a reactive function that changes according to the user input selections as follow:


  ui <- 

  dashboardSidebar( sliderTextInput(
  inputId = "mySliderText", 
  label = "Story line", 
  grid = TRUE, 
  force_edges = TRUE,
  choices = c('1','2')
             title = "Operations ", 
             closable = FALSE, 
             width = 9,
             status = "primary", 
             solidHeader = FALSE, 
             collapsible = TRUE,

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

 operations_reactive <- reactive({
 if (input$mySliderText ==1)

 shinyApp(ui = ui, server = server)

it works but not in a proper way, the operations_reactive does not change when input$mySliderText changes

the code your provided did not work at all out of the box for me and required the following 3 things

  1. adding library(shinywidgets) as sliderTextInput is used
  2. adding an empty dashboardHeader() as otherwise dashboardPage complained
  3. added trivial trial1.html and trial2.html files to my working directory, i made the contents of these <p>trial1</p> and <p>trial2</p> respectively.
    Having made these changes the app ran; also seemed to behave perfectly as I expected.
1 Like

I didn't get it where I should add <p>trial1</p> and <p>trial2</p> ? . Thank you for you support!

in files called trial1.html and trial2.html.
your code mentioned them.

Could you please show me how this should looks like, Thank you in advance!


I already have content inside my trial1.html and trial2.html so when I add what you have recommended I get this:

and is there a problem ?

yes still I get only one of the HTML files not both of them, I mean the reactive doesn't change the files

the setup with the barebones html files works for me, therefore I can only assume something relevant to your problem appears in your different html (that I dont have access to) or else, the code you are trying is not quite the code you provided here plus my fixes... or there is some package version issue though this seems unlikely to me given the context.

if you remove all the content from trial1.html and trial2.html apart from the initial

i.e. get closer to the example that does in fact work on my machine, then does it start to work for you ?

1 Like

Fist of all I really appreciate your efforts and the generous support, I think the problem with the HTML files that I have. I tested the code with a very simple HTML that contains as you have suggested:
<p>trial1</p> and <p>trial2</p>, it works perfectly.
I attached to you under the following link my HTML files, and I would be grateful if you could give it a look and hopefully figure out what its problem:

These files are not pure HTML, they seem to contain significant amounts of javascript.
The script parts which simply embed images are fine, I tested that.
How did you create/come by these HTML ?
I would try to produce them or edit them down, to remove all non-essential javascript.

yes you are right, I created them through R markdown so they are not pure HTML

So, I recommend you alter your markdown to reduce it to minimal html/images and not to worry in principle this would include the detail and summary functions that your examples use . i.e <details>: The Details disclosure element - HTML: HyperText Markup Language | MDN
this is pure HTML and doesnt need more javascript.

good luck !

1 Like

You are awesome! the problem has been solved based on this solution. Many thanks!

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