tooth-paste Posted May 31, 2018 Posted May 31, 2018 How can I make a form with a formula. Does anyone have ideas. Example: Inputfield 1: variable #1 Inputfield 2: variable #2 Inputfield 3: variable #3 #1 - #2 -(#3 x 1.8) RESULT
bernhard Posted May 31, 2018 Posted May 31, 2018 http://lmgtfy.com/?q=javascript+form+formula You just need some very basic HTML + some very basic JavaScript 4
kixe Posted May 31, 2018 Posted May 31, 2018 If you need this for the backend (result available in frontend too) you can use FieldtypeMarkup for the result. Grab the code from here: https://github.com/kixe/FieldtypeMarkup Create a hook with your formula and place the code in /site/ready.php The result will be populated after saving the page. /** * https://github.com/kixe/FieldtypeMarkup * FieldypeMarkup as concat field with formula * EXAMPLE * */ $wire->addHookAfter('FieldtypeMarkup::formatValue', function($e) { $page = $e->arguments[0]; $field = $e->arguments[1]; // quick exit if ($field->name != 'result') return; if ($page->template != 'calculator') return; $value1 = $page->inputfield1; $value2 = $page->inputfield2; $value3 = $page->inputfield3; $value4 = $pages->get(12345)->inputfield1; // get value from another page $result = $value3 * ($value2 - $value3) / $value4; // formula $e->return = $result; }); 3
Recommended Posts