Skip to content

Commit 689b350

Browse files
committed
multiple select support
1 parent 17eeed0 commit 689b350

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ vars:
270270
values: [ Raku, Rust, Golang ]
271271
type: select
272272
default: Rust
273+
multiple: true
273274
274275
-
275276
name: Color

js/misc.js

+13
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ function openTab(evt, tabName) {
1111
document.getElementById(tabName).style.display = "block";
1212
evt.currentTarget.className += " is-active";
1313
}
14+
15+
function getSelectValues(elm) {
16+
var result = [];
17+
var options = elm && elm.options;
18+
var opt;
19+
for (var i=0, iLen=options.length; i<iLen; i++) {
20+
opt = options[i];
21+
if (opt.selected) {
22+
result.push(opt.value || opt.text);
23+
}
24+
}
25+
return result;
26+
}

templates/build.crotmp

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<head>
33
<title>~SPARKY CI WEB~ | Build project: <.project> </title>
44
</head>
5+
<script src="/js/misc.js" type="text/javascript"></script>
56
<&HTML-AND-JAVASCRIPT(.navbar)>
67
<div class="panel is-primary">
78
<div class="panel-heading">
@@ -46,8 +47,14 @@
4647
</!>
4748
</?>
4849
<?{ $i.type eq 'select' }>
50+
<?{ $i.multiple }>
51+
<div class="select is-multiple">
52+
<select name="<$i.<name>>" multiple size="8">
53+
</?>
54+
<!{ $i.multiple }>
4955
<div class="select">
50-
<select name="<$i.<name>>">
56+
<select name="<$i.<name>>">
57+
</!>
5158
<@$i.values: $s>
5259
<?{ $i.default eq $s }>
5360
<option selected="selected"><$s></option>
@@ -118,10 +125,11 @@
118125
var e = document.getElementById("form01").elements["<$i.name>"];
119126
var t = "<$i.name>";
120127
<?{ $i.type eq 'select'}>
121-
var v = e.value;
122-
var v_text = e.options[e.selectedIndex].text;
123-
tags.push(`${t}=${v_text}`);
124-
console.log(`${t}: ${v}`);
128+
v_array = getSelectValues(e)
129+
v_array.forEach((v_text) => {
130+
tags.push(`${t}=${v_text}`);
131+
console.log(`${t}: ${v_text}`);
132+
});
125133
</?>
126134
<?{ $i.type eq 'textarea' or $i.type eq 'input' or $i.type eq 'password'}>
127135
var v = e.value;

0 commit comments

Comments
 (0)