diff options
author | Mark Wells <mark@freeside.biz> | 2013-05-31 17:02:48 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-05-31 17:02:48 -0700 |
commit | e0c23bec998267cf2d72ee2a98fa2a88ee1de066 (patch) | |
tree | ac44260604b86490503948dbef78658ed86247f9 | |
parent | 781a4348dd3cbe705d6265d36ac5e08b3ed5d01f (diff) |
better multiple-select behavior in part_svc edit, #23251
-rw-r--r-- | httemplate/edit/elements/part_svc_column.html | 3 | ||||
-rwxr-xr-x | httemplate/edit/part_svc.cgi | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/httemplate/edit/elements/part_svc_column.html b/httemplate/edit/elements/part_svc_column.html index d03c49d2f..fbea9bd6d 100644 --- a/httemplate/edit/elements/part_svc_column.html +++ b/httemplate/edit/elements/part_svc_column.html @@ -157,6 +157,9 @@ that field. 'multiple' => $def->{'multiple'}, 'disable_empty' => 1, 'curr_value' => $value, + # these can be switched between multiple and singular, + # so put the complete curr_value in an attribute + 'element_etc' => 'default="'.encode_entities($value).'"', &> % } else { % my (@options, %labels); diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 58c237efd..2ec024269 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -72,6 +72,17 @@ function flag_changed(obj) { select.className = 'enabled'; if ( newflag == 'S' || select.getAttribute('should_be_multiple') ) { select.multiple = true; + var defaults = select.getAttribute('default'); + if ( defaults ) { + defaults = defaults.split(','); + for (var i = 0; i < defaults.length; i++) { + for (j = 0; j < select.options.length; j++ ) { + if ( defaults[i] == select.options[j].value ) { + select.options[j].selected = true; + } + } + } + } } else { select.multiple = false; } |