There is a "select multiple" html tag. You'll have to dig into the html and
javascript docs on this and provide new jhs wrappers to make it easy to use
from J. I think the code will be trivial but the homework to figure out the
code will be more difficult. Depending on the app requirements a table of
checkboxes is another way to go (see jal for an example of this).

On Wed, Dec 14, 2011 at 3:24 AM, Ian Clark <earthspo...@gmail.com> wrote:

> Trying to port a j6 jwd app to j7 jhs. It has a listbox accepting
> multiple selections, defined like this:
>
>   xywh 5 16 244 100;cc panel listbox ws_vscroll lbs_multiplesel
> rightmove bottommove;
>
> The JHS framework offers a verb: jhselect to generate a Select object,
> which IMO is the thing to use in its place. But it only allows single
> lines to be selected.
>
> How do I get multiple selections, *plus* reading back what lines are
> selected?
>
> If I define a variant (the only difference from jhselect being that
> I've inserted 'multiple' in line 1) ...
>
> jhselectmultiple=: 4 : 0
> 'values size sel'=. y
> t=. '<select id="<ID>" name="<ID>" class="jhselect" size="<SIZE>"
> multiple onchange="return jev(event)" >'
> t=. t hrplc 'ID SIZE SEL';x;size;sel
> opt=. '<option value="<VALUE>" label="<VALUE>" <SELECTED>><VALUE></option>'
> for_i. i.#values do.
>  t=. t,opt hrplc'VALUE
> SELECTED';(i{values),(i=sel){'';'selected="selected"'
> end.
> t=. t,'</select>'
> )
>
> and call it in HBS with a line like this:
>
>   'sel'  jhselectmultiple  sel_text ; sel_size ; sel_index
>
> then this does indeed generate a Select object with id="sel" which
> accepts multiple selections.
>
> However, I can only see the first selection, using this javascript
> function (borrowed from jdemo4):
>
> function ev_sel_change()
> {
>  jbyid("which").innerHTML= JEV+" : "+jbyid("selm").selectedIndex;
> }
>
> I don't know the DOM well enough to know what I should be using instead.
>
> I've tried googling for selectedIndex and get this link:
> http://www.javascriptkit.com/jsref/select.shtml
> but it merely confirms that the above is the behavior of selectIndex
> when 'multiple' is specified, without suggesting what to use instead.
>
> (Does anyone know a better DOM reference link?)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to