Reputation: 1658
i have two select input in my UI.R library(shiny)
ContextElements = c("choice1", "choice2", "choice3")
shinyUI(pageWithSidebar(
headerPanel(""),
sidebarPanel(
h4("test for selectize input"),
selectizeInput(inputId = "firstAxe", label = h4("First Axe"),
choices=ContextElements, selected = NULL, multiple = FALSE,
options = NULL),
hr(),
selectizeInput(inputId = "twoAxe", label = h4("Second Axe"),
choices=NULL, selected = NULL, multiple = FALSE,
options = NULL)
),
mainPanel(
)
))
i want that the next selectizeinput choices ("twoAxe") to be filled dynamically with the remained choices drom the first one, that's mean if i choosed the first choice if the first one, the second choices will be choice2 and choice3
Thanks
Upvotes: 0
Views: 309
Reputation: 12684
You can do this in server.r
using updateSelectizeInput
. Lets assume that ContextElements
is available to the server - either defined in global.r
or in both server.r
and ui.r
. Then this should work:
observe({
input$firstAxe # makes the second selectize change when the first one does
updateSelectizeInput({session, inputId="twoAxe",
choices=as.list( ContextElements[!ContextElements %in% input$firstAxe] ) })
})
As you change you choice in firstAxe
you should see the choices in twoAxe
respond.
Upvotes: 0