2

I am trying to create a conditionalPanel that displays when a preceding input is filled out. I want the conditionalPanel to populate with choices based on the initial input.

My code looks something like this:

   selectInput("initialvalue", "Initial Value", c("Choose one" = "", as.character(initialvaluelist))),
   conditionalPanel(
     condition = "input.initialvalue=='First Option'",
     selectInput("conditionalchoices", "Conditional Choices", choices = c("Click to select from list" = "", firstoptionchoices), selected = NULL, multiple=TRUE)),
   conditionalPanel(
     condition = "input.initialvalue=='Second Option'",
     selectInput("conditionalchoices", "Conditional Choices", choices = c("Click to select from list" = "", secondoptionchoices), selected = NULL, multiple=TRUE))

In this example, choosing First Option would pull up firstoptionchoices and choosing Second Option would pull up secondoptionchoices.

This works in the UI, but only the first conditionalPanel condition updates the reactive variable. The second one does not. What am I missing?

Jeff
  • 209
  • 1
  • 10
  • 2
    Hi Jeff, I'm not sure that you can have two different `selectInput` functions with the same identifier. Giving the same ID twice would create two HTML elements with the same ID which is invalid HTML. – conrad-mac Feb 19 '17 at 01:12
  • Thanks conrad-mac! Your comment helped me get unstuck. I was able to solve this issue by creating a reactive variable for the conditional choices, and I put the `selectInput` as a `renderUI` output, as described [here](http://stackoverflow.com/questions/21465411/r-shiny-passing-reactive-to-selectinput-choices). – Jeff Feb 19 '17 at 01:44
  • Hi Jeff, I think it could be useful if you change your last comment to be the answer and accept it. Obviously adding the code as example. – Giacomo Sep 14 '17 at 09:15

0 Answers0