formaNumericInputUpdate: Update a Formatted Numeric Input Widget

Description Usage Arguments See Also Examples

Description

Update a Formatted Numeric Input Widget

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
updateCurrencyInput(
  session,
  inputId,
  label = NULL,
  value = NULL,
  format = NULL
)

updateFormatNumericInput(
  session,
  inputId,
  label = NULL,
  value = NULL,
  format = NULL
)

Arguments

session

Standard shiny session.

inputId

The id of the input object.

label

The label to set for the input object.

value

The value to set for the input object.

format

The format to change the input object to.

See Also

Other autonumeric: autonumericInput(), currencyInput(), updateAutonumericInput()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
if (interactive()) {
  library(shiny)
  library(shinyWidgets)

  ui <- fluidPage(
    tags$h2("Currency Input"),

    currencyInput("id1", "Euro:", value = 1234, format = "euro", width = 200, align = "right"),
    verbatimTextOutput("res1"),
    actionButton("bttn0", "Change Input to Euros"),
    actionButton("bttn1", "Change Input to Dollars"),
    actionButton("bttn2", "Change Input to Yen")
  )

  server <- function(input, output, session) {

    output$res1 <- renderPrint(input$id1)

    observeEvent(input$bttn0, {
      updateCurrencyInput(
        session = session,
        inputId = "id1",
        label = "Euro:",
        format = "euro"
      )
    })
    observeEvent(input$bttn1, {
      updateCurrencyInput(
        session = session,
        inputId = "id1",
        label = "Dollar:",
        format = "dollar"
      )
    })
    observeEvent(input$bttn2, {
      updateCurrencyInput(
        session = session,
        inputId = "id1",
        label = "Yen:",
        format = "Japanese"
      )
    })


  }

  shinyApp(ui, server)
}

Example output



shinyWidgets documentation built on Sept. 17, 2021, 5:06 p.m.