====== orderFormMatrix - Text entry matrix with quantities, prices, and totals ======
The **orderFormMatrix** function enables the creation of an order form with quantities, prices, and totals using a text entry matrix question.
Functionality and features include:\\
* Calculates item subtotals, total quantity, and total price as quantities are entered
* Price, subtotal, and total fields are read-only
* Tab to quantity inputs
* Allows only valid numeric input
* Saves all data, including prices, subtotals, and totals, in response data
* Supports specification of subtotal and total decimal places
* Supports whole number or decimal quantities
* Supports custom CSS styling (examples provided)
* Compatible with back button
Here is an example:\\
{{ ::orderformmatrix.mp4?800 |orderFormMatrix}}
This function is available for a reasonable fee. Contact **[[https://community.qualtrics.com/inbox/conversation?with=373|TomG]]** on the Qualtrics Community to learn more.
===== Set-up Instructions =====
==== Add Function To Survey ====
Add the orderFormMatrix function to the survey header to make it available to any question in the survey. Go to Look & Feel -> General -> Header edit -> {{::icon_source.jpg?20|}} and paste the provided orderFormMatrix function JS:
Alternatively, paste the orderFormMatrix function JS into a question's JS __outside__ the existing Qualtrics functions to make it available to questions on the page.
==== JavaScript Function Call ====
Add JS to call the orderFormMatrix function to apply it to the text entry matrix question as follows:
Qualtrics.SurveyEngine.addOnload(function() {
orderFormMatrix(this);
});
To override the default options, specify the desired **[[orderFormMatrix#Options|options]]** in the second function argument as an object. For example:
Qualtrics.SurveyEngine.addOnload(function() {
orderFormMatrix(this,{qtyDecimals:1});
});
==== Question Settings ====
* Matrix
* Matrix Type: Text entry
* Scale points: 3 (In order: Quantity, Price, Total)
* Statements: Items + Total as last row
* Default choices: Prices for all Items
==== Custom CSS ====
The orderFormMatrix function adds the class "ofm" to the question to enable custom CSS formatting of orderFormMatrix questions. This can be used to make totals bold, add currency symbols before or after prices, set the width of inputs, hide the price column (if prices are included in the item labels), etc.. Example CSS rules are provided with the orderFormMatrix function.
===== Options =====
==== qtyDecimals ====
**qtyDecimals** specifies the number of decimals allowed in quantity fields.
Default: 0
==== totalDecimals ====
**totalDecimals** the number of decimal places that should be displayed in the price subtotals and total. Amounts are rounded if necessary.
Default: 2
====== Qualtrics Wiki ======
[[start|Qualtrics Wiki]]