Score Setup & Calculation
Initializing and displaying scores.
Last updated
Was this helpful?
Initializing and displaying scores.
Last updated
Was this helpful?
Learn how to initialize and display scoring variables in your forms. Scoring variables allow you to track and show scores (or any numeric values) dynamically based on user interactions.
Attribute: sf-score
Value: Comma-separated variable names (e.g., "ross, monica")
Where: Form Container
HTML Example
Webflow Example
To display the scores, use the sf-react
attribute with the text()
function to bind the score values to elements in your form.
HTML Example:
Webflow Example:
Implementing Dynamic Scoring
Understand how to calculate scores using different methods available in Superform. Customize scoring logic to suit various form requirements.
Attribute: sf-score-calc
Where: Input elements (radio buttons, checkboxes)
add(condition, variable, value)
: Adds value to variable if condition is true
.
minus(condition, variable, value)
: Subtracts value from variable if condition is true
.
multiply(condition, variable, value)
: Multiplies variable by value if condition is true
.
divide(condition, variable, value)
: Divides variable by value if condition is true
.
HTML Example
Scoring variables can also be used in various elements and contexts beyond simple text display. Here are some imaginary examples:
Enabling/Disabling Class:
If Ross's score is lower than Monica's activate an is-disabled
class for the bonus button.
Showing/ Hiding Elements:
If Ross's score is more than 5
, show a text with "Special reward unlocked for Ross!"
Pro Tips
Initialization: Ensure scoring variables are correctly set in the sf-score
attribute.
Dynamic Display: Use sf-react
to dynamically update and display scores based on user interactions.
Versatility: Utilize scoring variables to influence various form elements, enhancing interactivity and user engagement.
For more details on $v
and other form variables, refer to the .