Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

can't mulitselect non-adjacent items

Questions related to using nuBuilder Forte.
Post Reply
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

can't mulitselect non-adjacent items

Unread post 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!
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: can't mulitselect non-adjacent items

Unread post by kev1n »

Ctrl + click items instead.
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: can't mulitselect non-adjacent items

Unread post 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.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: can't mulitselect non-adjacent items

Unread post 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"));
    }

}
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: can't mulitselect non-adjacent items

Unread post by kev1n »

Or use this code, if there is more than 1 multi select:

https://github.com/smalos/nuBuilder4-Co ... t_ctrl_key
Last edited by kev1n on Fri Sep 04, 2020 5:39 pm, edited 1 time in total.
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: can't mulitselect non-adjacent items

Unread post by benritter »

YES! brilliant thanks!
Post Reply