Page 1 of 1

Limit List box

Posted: Fri Jun 21, 2019 3:23 am
by JeniferAntony
Hello All,
I need to limit the Multi select list box to 2. User could select only 2 values.
Refer the link: https://wiki.processmaker.com/3.0/Dropd ... %20Listbox
Regrads,
Jenifer

Re: Limit List box

Posted: Fri Jun 21, 2019 3:26 am
by JeniferAntony
Please help me to achieve this. User can select 2 values then the list should be disabled. But at the same time user can de-select the values which is already selected. Then all the options should be available as the length is one.
If the length is equal to 2 then we need to block the selection.

Re: Limit List box

Posted: Tue Jun 25, 2019 2:19 am
by amosbatto
JeniferAntony wrote: Fri Jun 21, 2019 3:23 am Hello All,
I need to limit the Multi select list box to 2. User could select only 2 values.
Refer the link: https://wiki.processmaker.com/3.0/Dropd ... %20Listbox
Regrads,
Jenifer
I created a programming example to explain this:
https://www.pmusers.com/index.php/Minim ... _a_listbox

Re: Limit List box

Posted: Tue Jun 25, 2019 2:25 am
by amosbatto
JeniferAntony wrote: Fri Jun 21, 2019 3:26 am Please help me to achieve this. User can select 2 values then the list should be disabled. But at the same time user can de-select the values which is already selected. Then all the options should be available as the length is one.
If the length is equal to 2 then we need to block the selection.
You can disable the listbox with this code:
$("#myListboxId").getControl().prop("disabled", true);

But if you do that, then there is no way to change the selected items. You will have disable individual options in the listbox. Sorry, but I'm already spent an hour preparing the previous example for you so you will have to figure it out on your own.

Re: Limit List box

Posted: Tue Jun 25, 2019 2:31 am
by JeniferAntony
Hello Amos,
Thank you for your effort and solution provided.
I will try to do the rest.
Regards,
Jenifer

Re: Limit List box

Posted: Tue Jun 25, 2019 9:30 pm
by amosbatto
Oh, I just noticed that you posted this under ProcessMaker 2. Are you using version 2?

Re: Limit List box

Posted: Wed Jun 26, 2019 12:23 am
by JeniferAntony
Hello Amos,

Sorry it was a mistake.
I am using 3.3.

Re: Limit List box

Posted: Wed Jun 26, 2019 1:19 am
by JeniferAntony
Hello Amos,

The following solution is working.
Code: Select all
$("#var_Dropdown_Multiselect").setOnchange(function(newVal, oldVal){
    if (newVal.length > 3) {      
    $("#var_Dropdown_Multiselect").setValue(eval(oldVal));
   }  
});