Jump to content

Help:NumberInput

From RiskiPedia

Help:NumberInput

The `<numberinput>` tag creates a native numeric input field with spinner arrows that lets the user enter or adjust an integer or decimal value. When the user finishes editing (presses Enter, clicks away, or uses the arrows), the value is saved to a page-state variable and any RiskModels or RiskDisplays that use it are automatically recalculated.

Syntax

The `<numberinput>` tag supports these attributes:

  • `min`: (Optional) Minimum allowed value. Defaults to no limit.
  • `max`: (Optional) Maximum allowed value. Defaults to no limit.
  • `step`: (Optional) Increment size for arrow buttons and mouse wheel. Use `1` for integers, `0.1`, `0.01`, etc. for decimals. Defaults to `1`.
  • `default`: (Optional) Initial value when the page first loads (or when no saved value exists). Must be a valid number.
  • `name`: (Required for saving and calculations) The page-state variable name that stores the selected value.

Basic syntax:

<numberinput min="0" max="200" step="5" default="100" name="quantity" />

Examples

Basic Number Input

A simple integer input from 0 to 150:

<numberinput min="0" max="150" name="age" />

Age:

Decimal Values

Allow half-point increments (e.g., for ratings):

<numberinput min="0" max="10" step="0.5" default="7.5" name="pain_score" />

Pain Level:

Negative Numbers

Temperature selector:

<numberinput min="-50" max="50" step="1" name="temperature" />

Temperature:

Use with RiskDisplay

<riskdisplay>Age={age}
Pain Score={pain_score}
Temperature={temperature}</riskdisplay>

Notes

  • The `name` attribute is required if you want the value to be used in RiskModel/RiskDisplay calculations.
  • If `default` is outside the `min`–`max` range, it is automatically clamped.
  • Decimal steps (e.g. `step="0.01"`) are fully supported.

Troubleshooting

  • Value doesn’t save or models don’t update → Make sure the `name` attribute is present and correctly spelled.