Support onchange for select boxes
[misc/kostenrechnung] / lib / mask.php
index fc49454..f5e890c 100644 (file)
@@ -49,8 +49,13 @@ function build_form($name, $mask)
       $ret[] = sprintf('<label for="edit_%s">%s</label><br>', $id, $info['name']);
       $ret[] = sprintf('<input type="checkbox" id="edit_%s" name="%s">', $id, $id);
     } elseif ($info['type'] == 'select') {
+      $v = array('id="edit_'.$id.'"',
+                'name="'.$id.'"');
+      if (array_key_exists('onchange',$info))
+       $v[] = sprintf('onchange="%s"', $info['onchange']);
+
       $ret[] = sprintf('<label for="edit_%s">%s</label><br>', $id, $info['name']);
-      $ret[] = sprintf('<select id="edit_%s" name="%s">', $id, $id);
+      $ret[] = sprintf('<select %s>', implode(' ', $v));
       if (is_array($info['options'])) $options = $info['options'];
       else $options = query_db($info['options']);
       foreach ($options as $row)