Superform by Delta Clan
✨ ClonablesSocialResourcesSuperform Home
v2
v2
  • 🏁Getting Started
    • Introduction
    • Quick Start
  • 🫀Essentials
    • Form Container
    • Step Container
    • Navigation - Overview
      • Direct
      • Logic / Conditional
      • Hook
    • Variables
      • Form Data ($f)
      • Step Index ($s)
      • Progress Percentage ($p)
      • Scoring Variables ($v)
    • Progress Bar
    • Reset
    • Radio Groups
    • Checkbox Groups
    • Cheatsheet
  • ⚙️Global Options
    • Step Delay Controls
    • Animations
      • Step Animation
      • Step Animation Duration
      • Step Animation Ease
    • Save Data & Progress
    • Pre-fill Form
    • Prevent Content Flash
    • Debug
    • Third-party Integrations
    • Cheatsheet
  • 🎛️Input Validation & Errors
    • Validation
      • length()
      • words()
      • minmax()
      • checkbox()
      • must()
      • hook()
    • Error Management
      • Automatic Error Setup
      • Manual Error Setup
  • ⚡Reactivity
    • Update Text
    • Visibility
    • Class Toggle
    • Value
    • Set Attribute
  • 🔢Score Tracking
    • Score Setup & Calculation
    • Score Ranking
  • ⌨️Accessibility
    • Enter & Backspace Bindings (↩, ⌫)
    • Checkbox & Radio Bindings
  • 🛠️Javascript SDK
    • Intro to Superform API
    • Superform Instance
    • Cheatsheet
  • 📖Additional Resources
    • WTF is an expression ? 🆕
    • Integrations
    • Tutorials
    • Changelog
    • FAQ 🚧
    • Join Discord
Powered by GitBook
On this page
  • Setup
  • Example
  • Hidden Input for Dynamic Score Tracking

Was this helpful?

  1. Reactivity

Value

Dynamic value assignment anywhere.

Since 2.1.10 (3 Oct 2024)

The value(expression) allows you to dynamically set values within your form, making it easy to mirror or calculate values in real-time and pass into form data. This is especially useful for hidden fields, quiz scoring, dynamic data submission, or any context where data needs to be stored or modified without direct user input and sent through email.

Setup

Attribute: sf-react = value(expression) (see WTF is an expression?)

Where: any HTML element with value attribute. The value attribute can be used with the following elements: <input>, <data>, <button>, <meter>, <li>, <option>, <progress>, and <param>, <output>

Description: dynamic addition of value on an element based on the evaluation of a specified expression.

Key Usage Scenarios:

  • Hidden Inputs: Set hidden input values dynamically based on user actions for later submission.

  • Quizzes and Score Tracking: Update quiz scores or similar dynamic values on the fly as users interact.

  • Dynamic Mirroring: Reflect data from one field into another, such as calculating and showing total scores or combining form entries.


Example

Hidden Input for Dynamic Score Tracking

We’re setting a hidden input’s value based on quiz answers so they can be pass into email data.

<!-- Form Container -->
<div sf="quizForm" sf-score="totalScore">
    <!-- Step -->
        <!-- Question with Score Calculation -->
        <input type="checkbox" sf-score-calc="add(checked, quizScore, 1)">
        <label>Question 1</label>

        <!-- Hidden input for total score -->
        <input type="hidden" name="totalScore" sf-react="value($v.quizScore)">
</div>

Here, the hidden input's value will reflect the total quizScore as users check/uncheck items, making it ready to submit with the form.

Last updated 2 months ago

Was this helpful?

⚡