selectizeInput ID is null


I'm trying to use javascript to refer to an selectizeinput but the ID comes back null even if I see it in the page source for .

I try to use :
I look at the page source HTML and see:

<select id="myid" class="form-control" multiple="multiple">

I got the outerhtml

<input type="text" autocomplete="off" tabindex="" style="width: 25.2344px; opacity: 1; position: relative; left: 0px;" placeholder="ALL">

I see no ID, any thoughts how I could use javascript to get the ID of the <select>?

Here's a small shiny app that I ran and inspected in Chrome:


ui <- fluidPage(
    inputId = "filter_carb",
    label = "Filter 1: carb",
    selected = 1,
    choices = unique(mtcars$carb)

server <- function(input, output) {

shinyApp(ui = ui, server = server)

I'm able to access the value and/or text of the selectizeInput by the following jQuery statements:

$("#filter_carb :selected").text()
$("#filter_carb :selected").val()

Does that work for you?


1 Like