1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class Horde_Form_Action_updatefield extends Horde_Form_Action {
16:
17: var $_trigger = array('onchange', 'onload', 'onkeyup');
18:
19: function getActionScript(&$form, &$renderer, $varname)
20: {
21: return 'updateField' . $this->id() . '();';
22: }
23:
24: function setValues(&$vars, $sourceVal, $arrayVal = false)
25: {
26: }
27:
28: function printJavaScript()
29: {
30: $this->_printJavaScriptStart();
31: $pieces = explode('%s', $this->_params['format']);
32: $fields = $this->_params['fields'];
33: $val_first = (substr($this->_params['format'], 0, 2) == '%s');
34: if ($val_first) {
35: array_shift($pieces);
36: }
37: if (substr($this->_params['format'], -2) == '%s') {
38: array_pop($pieces);
39: }
40:
41: $args = array();
42: if ($val_first) {
43: $args[] = "document.getElementById('" . array_shift($fields) . "').value";
44: }
45: while (count($pieces)) {
46: $args[] = "'" . array_shift($pieces) . "'";
47: $args[] = "document.getElementById('" . array_shift($fields) . "').value";
48: }
49: ?>
50: .
51: function updateField<?php echo $this->id() ?>()
52: {
53: var target = document.getElementById('<?php echo $this->getTarget() ?>');
54: if (target) {
55: target.value = (<?php echo implode(' + ', str_replace("\n", "\\n", $args)) ?>).replace(/(^ +| +$)/, '').replace(/ +/g, ' ');
56: }
57: }<?php
58: $this->_printJavaScriptEnd();
59: }
60:
61: }
62: