1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17: class Horde_Form_Action_sum_fields extends Horde_Form_Action {
18:
19: var $_trigger = array('onload');
20:
21: function getActionScript(&$form, $renderer, $varname)
22: {
23: Horde::addScriptFile('form_helpers.js', 'horde');
24:
25: $form_name = $form->getName();
26: $fields = "'" . implode("','", $this->_params) . "'";
27: $js = array();
28: $js[] = sprintf('document.forms[\'%s\'].elements[\'%s\'].disabled = true;',
29: $form_name,
30: $varname);
31: foreach ($this->_params as $field) {
32: $js[] = sprintf("addEvent(document.forms['%1\$s'].elements['%2\$s'], \"onchange\", \"sumFields(document.forms['%1\$s'], '%3\$s', %4\$s);\");",
33: $form_name,
34: $field,
35: $varname,
36: $fields);
37: }
38:
39: return implode("\n", $js);
40: }
41:
42: }
43: