Debian Codegraph @

man/updateNumericInput.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/update-input.R
3 \name{updateNumericInput}
4 \alias{updateNumericInput}
5 \title{Change the value of a number input on the client}
6 \usage{
7 updateNumericInput(
8 session = getDefaultReactiveDomain(),
9 inputId,
10 label = NULL,
11 value = NULL,
12 min = NULL,
13 max = NULL,
14 step = NULL
15 )
16 }
17 \arguments{
18 \item{session}{The \code{session} object passed to function given to
19 \code{shinyServer}. Default is \code{getDefaultReactiveDomain()}.}
20
21 \item{inputId}{The id of the input object.}
22
23 \item{label}{The label to set for the input object.}
24
25 \item{value}{Initial value.}
26
27 \item{min}{Minimum allowed value}
28
29 \item{max}{Maximum allowed value}
30
31 \item{step}{Interval to use when stepping between min and max}
32 }
33 \description{
34 Change the value of a number input on the client
35 }
36 \details{
37 The input updater functions send a message to the client, telling it to
38 change the settings of an input object. The messages are collected and sent
39 after all the observers (including outputs) have finished running.
40
41 The syntax of these functions is similar to the functions that created the
42 inputs in the first place. For example, \code{\link{numericInput}()} and
43 \code{updateNumericInput()} take a similar set of arguments.
44
45 Any arguments with NULL values will be ignored; they will not result in any
46 changes to the input object on the client.
47
48 For \code{\link{radioButtons}()}, \code{\link{checkboxGroupInput}()} and
49 \code{\link{selectInput}()}, the set of choices can be cleared by using
50 \code{choices=character(0)}. Similarly, for these inputs, the selected item
51 can be cleared by using \code{selected=character(0)}.
52 }
53 \examples{
54 ## Only run examples in interactive R sessions
55 if (interactive()) {
56
57 ui <- fluidPage(
58 sliderInput("controller", "Controller", 0, 20, 10),
59 numericInput("inNumber", "Input number", 0),
60 numericInput("inNumber2", "Input number 2", 0)
61 )
62
63 server <- function(input, output, session) {
64
65 observeEvent(input$controller, {
66 # We'll use the input$controller variable multiple times, so save it as x
67 # for convenience.
68 x <- input$controller
69
70 updateNumericInput(session, "inNumber", value = x)
71
72 updateNumericInput(session, "inNumber2",
73 label = paste("Number label ", x),
74 value = x, min = x-10, max = x+10, step = 5)
75 })
76 }
77
78 shinyApp(ui, server)
79 }
80 }
81 \seealso{
82 \code{\link[=numericInput]{numericInput()}}
83 }