Looking for creative input in order to handle a dynamic numeric input issue I have.

I apologize in advance, I can't include my code ex. due to work restrictions. However it's fairly simple to describe and I'm just looking for direction. How would you solve this intuitively.

I have Shiny app that is bare bones. It will look to the user for input parameters for a DB query. There are two ways to search my DB. Option A- which has three additional numeric inputs or Option B which also has three additional numeric inputs.

So start off I have SelectInput dropdown box with the two options. (A & B). And what i want to do next is have a dynamic numeric input based on the previous selection. This needs to have three unique fields.

So user selects:
Option A: then has access to
numeric input 1:
numeric input 2:
numeric input 3:

this would be the same for option B. the input fields are all unique
I want to only show the unique options for each drop down when selected
Any ideas how to best accomplish this? Conditional panel? Dynamic UI

Wrap the options being sent to the first selectInput in observe and use updateSelectInput in the statement. Then, for the inputs dependent on this selection, wrap those filtered options in observeEvent that is observing the selectInput id. Again, using updateNumericInput to update these options based on whatever is selected in selectInput.

UI:

selectInput(inputId='selectid',label="Select A or B",choices=NULL)
numericInput(inputId="numericid1",label="Numeric Input 1")
`
`

Server:

observe({
    selectoptions <- c("A","B")
    updateSelectInput(inputId="selectid",choices=selectoptions)
})
observeEvent({input$selectid},{
   #Some code that chooses the correct range of numeric inputs given A or B
  updateNumericInput(inputId="numericid1",min=Some number,max=Some number)
  `
  `
})
1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.