Anyone who can write an APL function should be able to host it on the web.™
Rendered webpage |
APL code |
:Class SelectAdvanced : MiPageSample
⍝ Control:: _DC.Select
⍝ Description:: Select one or more fruits from a list.
FRUITS←'Apples' 'Bananas' 'Grapes' 'Oranges' 'Pears' 'Pineapples' 'Plums'
VEGGIES←'Beans' 'Carrots' 'Eggplant' 'Peppers' 'Spinach'
∇ Compose;frm;btn
:Access public
Add _.h2'Please pick some fruits'
(frm←Add _.Form).id←'myform'
mult←'multi'frm.Add _.Select(FRUITS(2 5)) ⍝ preselect 2nd and 5th fruit
mult.Set'multiple' 1 ⍝ Allow multiple selections
mult.Set'required' 1 ⍝ No call back unless there is a selection
mult.Set'size'(⊃⍴FRUITS) ⍝ Make room for all the items
mult.Set'autofocus' 'true' ⍝ Put the focus here
frm.Add _.br
btn←'PressMe'frm.Add _.Button'Pick Fruits'
btn.On'click' 'onPick'
btn2←frm.Add _.Button'Switch to Veggies'
btn2.On'click' 'onSwitch'
(btn btn2).style←⊂'margin-top: 10px; margin-bottom: 10px;'
'output'Add _.div
∇
∇ r←onPick;selected;selection
⍝ Called when the Pick button is pressed
:Access Public
selection←eis Get'multi'
selected←1↓∊' ',¨selection
r←'#output'Replace _.p('You picked: ',selected,(0=⍴selected)/'nothing')
∇
∇ r←onSwitch;selected;selection
⍝ Called when the Switch button is pressed
:Access Public
r←mult.ReplaceOptions VEGGIES
∇
:EndClass