Page 1 of 1

can't mulitselect non-adjacent items

Posted: Thu Sep 03, 2020 4:59 pm
by benritter
Hi,
I have a mulit-select object with 4 options. If I click and drag I can select adjacent items. But if I try to click separately on non-adjacent items, it de-selects the first one. I'm considering just creating new fields for each item and using check boxes instead. But the multi-select would make it easier to add or change items later on.
Thanks!

Re: can't mulitselect non-adjacent items

Posted: Thu Sep 03, 2020 5:04 pm
by kev1n
Ctrl + click items instead.

Re: can't mulitselect non-adjacent items

Posted: Thu Sep 03, 2020 5:07 pm
by benritter
I know that would work but I'm building this app for people that probably wouldn't know that trick so I was hoping to keep it simple.

Re: can't mulitselect non-adjacent items

Posted: Thu Sep 03, 2020 6:13 pm
by kev1n
Add this JavaScript to your form's custom code. Replace your_select_id with the Object ID of your select object.

Code: Select all

if (nuFormType() == 'edit') {

    your_select_id.onmousedown = function (event) {
        if (event.shiftKey) return;
        event.preventDefault();
        this.focus();
        var scroll = this.scrollTop;
        event.target.selected = !event.target.selected;
        this.scrollTop = scroll;
        this.dispatchEvent(new Event("change"));
    }

}

Re: can't mulitselect non-adjacent items

Posted: Thu Sep 03, 2020 6:33 pm
by kev1n
Or use this code, if there is more than 1 multi select:

https://github.com/smalos/nuBuilder4-Co ... t_ctrl_key

Re: can't mulitselect non-adjacent items

Posted: Thu Sep 03, 2020 7:13 pm
by benritter
YES! brilliant thanks!