This topic is locked
[SOLVED]

Set multiple choices in a checkbox lookup list via javascript

11/23/2022 10:53:45 AM
ASPRunner.NET General questions
T
Tim author

Hi all,

I have an edit page that has a lookup field that is a checkbox list. The list of options is very long and I have some buttons that I'd like the user to be able to click to "pre-select" choices in the list. I've got it working if the button is just ticking one checkbox in the list. Here is that code:

var ven = Runner.getControl(pageid,'Vendors');

ven.setValue('3');

This selects the vendor with the ID of '3'. Now I want a button that selects multiple choices from the list, so vendor IDs '3','25', and '234'. When I try to set the values of the field to a comma seperated list it doesn't work. Here is what I've tried:

var ven = Runner.getControl(pageid,'Vendors');

ven.setValue('3','25','234');

I also tried:

var ven = Runner.getControl(pageid,'Vendors');

ven.setValue('3,25,234');

The second one doesn't work at all. The first one ticks the first ID in the list, but not the subsequent IDs.

Can someone help me with the syntax to set multiple options?

Thanks,
Tim

admin 11/23/2022

I've checked with developers, this can be done and you need to pass an array as an argument.

ven.setValue( [1,10,12] );

T
Tim author 12/8/2022

Sorry, I forgot to reply. This did the trick. Set an arry inside of [ ] brackets. Got it. Thanks so much for the help.

Thanks,
Tim