sS hselect(S name, Map map, O... params) { ret hselect(map, paramsPlus_skipFirst(params, +name)); } sS hselect(Map map, O... params) { new StringBuilder buf; S selected = null; if (odd(l(params))) { selected = str(first(params)); params = dropFirst(params); } int i = indexOf(params, "allowEmpty"); if (even(i)) { buf.append("<option></option>\n"); params[i] = params[i+1] = null; } if (nempty(map)) for (O key : keys(map)) { O value = map.get(key); S k = str(key); buf.append(tag("option", htmlencode(str(or(value, ""))), value := k, selected := eq(selected, k) ? "selected" : null)).append("\n"); } ret tag("select", buf, params) + "\n"; }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1007620 |
| Snippet name: | hselect - HTML <select> tag from map - hselect([name,] map, [selected key,] params) |
| Eternal ID of this version: | #1007620/10 |
| Text MD5: | 8f1965ece4a948e8842e4e6169843ff0 |
| Author: | stefan |
| Category: | javax / html |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-06-10 14:00:20 |
| Source code size: | 728 bytes / 25 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 727 / 777 |
| Version history: | 9 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1007635 - hselect_allowEmpty - HTML <select> tag from map - OLD - use hselect instead #1013066 - hselect_list - HTML <select> tag from list of strings - hselect_list([name,] entries, [selected key,] params) |