JQuery plugin to manage operations between fields and/or html elements
$('result_field_selector').operation('query_string');OR
options = {query: 'your query'};
$('result_field_selector').operation(options);It can be used on HTML elements other than INPUT too!
| Option | Default | Input |
|---|---|---|
| query | - | Mathematical expression with jquery selectors between {} ('1 + {#my-field}') |
| events | ['change'] | array of events that trigger recalculation (event on query elements) |
| checkNew | false | if set to true checks for fields inserted in the DOM after initialization |
| timedCheck | 0 | check changes every specified milliseconds (n <= 0 is disabled) |
| fieldsDecimalSeparator | '.' | decimal separator used in the input fields |
| fieldsThousandSeparator | '' | thousand separator used in the input fields |
| resultDecimalSeparator | '.' | decimal separator used in the result field |
| resultThousandSeparator | '' | thousand separator used in the result field |
| decimalDigits | -1 | to fix the number of decimal digits in the result input a number 0 <= n <= 20 |
If a selector has been used for multiple fileds ('{.myfields}' or others) it calculates all their values (prioritizing multiplications and divisions)
EXAMPLE
$('#result selector').operation('... - 1 + {.myfields} * 5 ...');//it will become:('... - 1 + {myfields 1 value} * {myfields 2 value} * ... * 5);
IF YOU WANT THAT TO BE A SUM
$('#result selector').operation('... - (1 + {.myfields}) * 5 ...'); //...add parenthesis!! ;)