Template:Form calculator/doc

This template is for creating form calculators in a standardised way. This implements the syntax of RuneScape:Calculators/Form calculators as a template.

About
A brief rundown of how form calculators work:
 * 1) The configuration is defined on the page by an editor; either using this template or using plain code
 * 2) * This code includes two unique identifiers, one for the form and one for the result
 * 3) * It also includes the name of a template
 * 4) The the template adds a usage of each of the IDs, to define where the form and result go (the editor can do this manually if they prefer)
 * 5) When the page loads, the javascript detects the config (specifically the   class) and reads it in
 * 6) The javascript generates the form from the config and places it in the location defined by the form ID, replacing what is there already
 * 7) The user inputs their data and presses submit
 * 8) The javascript builds a query to the MediaWiki API which processes the template, and sends it
 * 9) * Think of this like editing a page with just the template on it, changing the values and pressing preview
 * 10) The response to the query comes back and is placed into the result ID, replacing what is there already
 * 11) Repeat from 5

template
Required. The template associated with the form. This is equivalent to what you would place inside.

If the template is in the Template: namespace, the Template: prefix can be omitted. Other namespaces are required - mainspace is used by a preceding colon only (i.e. ).

form
Required. A unique identifier for the form. Make sure this is sufficiently descriptive so it cannot clash with general IDs on the page.

For example,.

result
Required. A unique identifier for the result. Like, make sure it is sufficiently unique.

For example,.

suggestns
Optional. A comma-separated list of namespace IDs to use in autocomplete fields. See RuneScape:Calculators/Form calculators for a list of IDs. Should be omitted if no parameters use the  type.

outputtype
Optional. This defines the type of automatically created form/result location is used. The relevant values are: [standard form message] [standarad result message]
 * - Default. No form/result location is created, so user can define their own.
 * - A simple output which has the form directly above the result (separated by two line breaks) with no additional formatting. Most form calculators where the result is a table will use this. Equivalent to:
 * - A wikitable with the form placed directly above the result, with some generic headers. This is best for small forms and results. Example: []
 * - An unstyled table with the result to the right of the form. This is a good way of having the form and result horizontally adjacent to each other.

Parameter definition
Any number of parameters can be defined. Each parameter defines a row in the form, and has 5 components:
 * param
 * label
 * type
 * range
 * default

These are followed by a number - param1, label1, etc. Things with the same number refer to the same row of the form.

No parameters are required - though a no-parameter form calculator is weird. However, if a parameter is defined, only  is required (though some combinations of ,  , and   are invalid).

Parameters are processed in numerical order starting at 1, and ending when one cannot be found. If you define a  and a , it won't process.

param
The parameter of the template. This is the name of the parameter which will be passed to the template when submitted.

label
The [user-friendly] label to display in the form. The default value is the corresponding. The label can contain most normal wikitext: links, images, spans with styles and titles (hover-overs), etc.

type
The type of input for this param. This can be used to restrict user input, or change the input field to a different type. It can be one of:
 * - Default. Text input field, no restriction.
 * - Text input field, no restrictions. Enables autocomplete for this field, based on the  parameter.
 * - Numbers. Text input field, set to number. Will prevent non-numbers being submitted.
 * - Integers. Text input field, set to number. Will prevent non-integers being submitted.
 * - Drop-down menu generated from the corresponding.
 * - Checkbox for submitting a boolean choice.
 * - Text input field, no restriction. Generates a lookup button to get data from hiscores, and updates the other fields as defined by.
 * - The default value provided is shown but cannot be changed. Can be used as a separator or for in-form notes.
 * - The default value provided is hidden from the form entirely. Used to pass things to the template that shouldn't be seen or changed by the user.
 * - The default value provided is hidden in the form, but still present in the HTML. This is for inter-script usage.

If anything other than those values are entered (or the parameter is omitted),  is used.

range
The range for the parameter, or any other configuration.
 * ,,  ,  ,   - Unused.
 * ,  - Format min-max. If either max or min is omitted, infinity/negative infinity is assumed. For example,.
 * - A comma-separated list of the options for the drop-down.
 * - By default, the form will pass true if ticked, or false if unticked, to the template. This can be overriden by setting the range in the format true value,false value. (If you set your template to check for Yes/No instead of true/false, use this.)
 * - A list of lists defining which other fields to change and what to change them to:
 * The small lists are defined in format param,skill,value:
 * param: the parameter to change
 * skill:the skill ID to find - skill IDs range from 0 to 50, per here
 * value: value to change it to - values are 0 for rank, 1 for level and 2 for experience
 * Each small list is separated from the next by a semicolon
 * For example,  will change the   field to the looked-up Crafting level, and the   field to the looked-up Agility experience.

default
The default value for the parameter in the form. This is pre-filled into the form when loaded.
 * ,  -  Defaults to empty.
 * ,  - Defaults to empty. Should respect the range given.
 * - One of the options given in the range.
 * - Unticked by default. Will be ticked by default if defined as  or the same as   in the range/
 * - Unused, does nothing.
 * ,,   - Can't be changed away from.