r - conditionalPanel in shiny based on number of items in inputSelect -


i trying implement conditionalpanel based on number of items in selectinput dropdown box.

i can condition work when based on value of dropdown per following (the textinput field allows set number of items in dropdown):

runapp(   list(ui =  fluidpage(     textinput("in_number", "number",1),     uioutput("dropdown"),     conditionalpanel("input.dropdown >= 3", p("show stuff"))   ),    server = function(input, output, session) {      output$dropdown <- renderui({       selectinput("dropdown","my dropdown", c(1:input$in_number))     })   }   ) ) 

however if change conditionalpanel be:

conditionalpanel("input.dropdown.length >= 3", p("show stuff")) 

then doesn't work. error message in developer tools console saying "cannot read property 'length' of undefined"

i assume how shiny defines dropdown items.

edit: clarify needs. there way javascript condition allow me assess number of items in dropdown, rather assessing value of dropdown?

i know mean now. suggest use shinyjs package , toggle functionality want.

rm(list = ls()) library(shiny) library(shinyjs) runapp(   list(ui =  fluidpage(     shinyjs::useshinyjs(),     textinput("in_number", "number",3),     uioutput("dropdown"),           p(id = "mydiv", "show stuff")   ),    server = function(input, output, session) {     output$dropdown <- renderui({       selectinput("dropdown1","my dropdown", c(1:input$in_number))     })          observe({       toggle(id = "mydiv", condition = as.numeric(input$in_number) >= 3)     })   }   ) ) 

enter image description here


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -