I want to filter the data based on selection of first select Input ( diploma). i.e if I select any diploma course, I shall get the filtered data in available1 select Input.
My code is-
ui<- fluidPage(useShinyjs(),
#extendShinyjs(text = "shinyjs.button = function() {window.scrollTo(0, 50);}"),
tags$head(tags$link(rel="stylesheet", href="style.css")),
titlePanel("Chatbot"),
fluidRow(column( width = 8,
div(id='outDiv',
panel(style = "overflow-y:scroll; max-height: 300px; position:relative; align: centre",
textInput("message", label = "",placeholder = "Type your message here."),
actionButton("send", "Send"), heading = "Smart Advisor", status = "primary")
)
)))
server<- function(input, output, session)
{
# Declaring and Initializing Global Variables
i <- 1
lvl <- reactiveVal()
lvl(i)
replyMessage<- function(lvl,msg)
{
message('Level:', lvl)
message('Message:', msg)
switch(lvl,
if(msg=='Diploma')
{
insertUI(selector = "#message", where = "beforeBegin",
ui=div(class="chat-bubbles",
div(class="bubble",
wellPanel(
p("As per your selection you are eligible for:", tags$br(),
selectInput("diploma_courses", "Disciplines", choices =c("All",unique(as.character(a1$`Discipline Category1`) )),
multiple = T)
)))))
observeEvent(input$diploma_courses,{
insertUI(selector = "#message", where = "beforeBegin",
ui=div(class="chat-bubbles",
div(class="bubble",
wellPanel(
p(
selectInput("available1", "Specialization", choices =c(as.character(a1$Subject1)[a1$`Discipline Category1`== input$diploma_courses])) )
))))
})
getMessage<- function(lvl)
{
# Observer Event for Message Box
observeEvent(input$send,{
if(input$message == '')
{
insertUI(
selector = "#message",
where = "beforeBegin",
ui=div(class="chat-bubbles",
div(class="bubble",p("Kindly provide a valid input."))
)
)
clearInput()
}
else
{
replyMessage(lvl(),input$message)
}
})
Solution