In this article
Note: Using the Survey Editor? See Number Element to learn how to use the Number element instead.
The <number> element is an open-ended question type that enables participants to provide an integer value for one or more response options.
The examples below demonstrate the different layouts available when working with <number> elements.
Note: <number> elements accept only whole number values. To collect decimal values, specify the element as a <float> type rather than a <number> type.
1: One-Dimensional
A one-dimensional <number> element requires an integer value to be provided for each row or column.
1.1: With No Rows
When no rows are specified, the number input box will appear directly beneath the question title. In this example, there are no rows. Participants provide a single integer value indicating their age.
<number label="Q1" optional="0" size="3">
<title>
Please enter your age.
</title>
<comment>Please enter a whole number</comment>
</number>
Result:
1.2: With Rows Only
When only rows are specified, the <number> element defaults to grouping responses by row. This means that a number input box is provided for each row. In this example, there are three rows and no columns. Participants indicate the number of items they own for each row.
<number label="Q2" optional="0" size="3">
<title>
How many of the following items do you currently own?
</title>
<comment>Please enter a whole number for each row</comment>
<row label="r1">TVs</row>
<row label="r2">Computers</row>
<row label="r3">Vehicles</row>
</number>
Result:
1.3: With Rows and a Column Header
When a single column is specified, the column header appears above the first number input box. This example is similar to the one above and demonstrates the difference when a column is added. In this example, there are three rows and a single column. Participants still indicate the number of items they own for each row.
<number label="Q2" optional="0" size="3">
<title>
How many of the following items do you currently own?
</title>
<comment>Please enter a whole number for each row</comment>
<col label="c1"># Owned</col>
<row label="r1">TVs</row>
<row label="r2">Computers</row>
<row label="r3">Vehicles</row>
</number>
Result:.
1.4: With Columns Only
When only columns are specified, the <number> element defaults to grouping responses by column. This means that a number input box is provided for each column. In this example, there are three columns and no rows. Participants indicate the number of times they ate a meal for each column.
<number label="Q3" optional="0" size="1">
<title>
How many times a week do you eat the following meals?
</title>
<comment>Please enter a whole number for each column</comment>
<col label="c1">Breakfast</col>
<col label="c2">Lunch</col>
<col label="c3">Dinner</col>
</number>
Result:
1.5: With Columns and a Row Legend
When a single row is specified, the row legend appears to the left of the response columns. This example is similar to the one above and demonstrates the difference when a row is added. In this example, there are three columns and a single row. Participants still indicate the number of times they ate a meal for each column.
<number label="Q3" optional="0" size="1">
<title>
How many times a week do you eat the following meals?
</title>
<comment>Please enter a whole number for each column</comment>
<row label="r1"># of meals eaten</row>
<col label="c1">Breakfast</col>
<col label="c2">Lunch</col>
<col label="c3">Dinner</col>
</number>
Result:
2: Two-Dimensional
A two-dimensional <number> element requires an integer value to be provided for each row and column.
2.1: Grouped by Rows
When multiple rows and columns are specified, the <number> element defaults to grouping responses by row. In this example, participants are asked to rate each aspect relative to the car brands provided. The question is equipped with both the verify and unique attributes, transforming it into an ideal ranking question.
The verify attribute ensures the integer values provided are between "1" and "4" and the unique attribute ensures that each value is unique per row. This means that a participant must enter a value from 1 to 4 without duplication.
<number label="Q7" optional="0" size="1" unique="1" verify="range(1, 4)">
<title>
On a scale from 1 - 4, please rate the following aspects of each car brand.
</title>
<col label="c1">Luxorious</col>
<col label="c2">Fast</col>
<col label="c3">Affordable</col>
<col label="c4">Good MPG</col>
<row label="r1">Tesla</row>
<row label="r2">Toyota</row>
<row label="r3">BMW</row>
<row label="r4">Ford</row>
</number>
Result:
2.2: Grouped by Columns
In contrast to the example above, responses for this question are grouped by column. Here, participants are asked to rate which car brands excel in the aspects provided.
Since the verify and unique attributes are still set, participants must provide a unique value from 1 to 4 for each column.
<number label="Q8" optional="0" size="1" unique="1" verify="range(1, 4)" grouping="cols">
<title>
On a scale from 1 - 4, please rate which car brands excel in the following areas.
</title>
<col label="c1">Luxorious</col>
<col label="c2">Fast</col>
<col label="c3">Affordable</col>
<col label="c4">Good MPG</col>
<row label="r1">Tesla</row>
<row label="r2">Toyota</row>
<row label="r3">BMW</row>
<row label="r4">Ford</row>
</number>
Result: