progamatically setting selected:true on mulitselect

Is there an options function similar to
form.getSelect(fId).options.remove( optIdx )
but rather selects the option?

I have an array of values that need to be checked (selected) in a multiselect control based on incoming values

var a = [ 'col1', 'col2' ];

            {type: "multiselect", name: "mselect", label: "Columns:",
              options: [ { text:'col1', value:'col1' },  { text:'col2', value:'col2' }, { text:'col3', value:'col3' } ] }

Given the above code, I need to select the col1 and col2 options. I would love to be able to say
form.getSelect().options.select( ‘col1’ );

Any input?

So as soon as I hit ‘send’, I thought to myself

var a = [ 'col'1, 'col'2 ];
// multiselect id = mId
form.setItemValue( mId, a );

And that works. The documentation for setItemValue should probably reflect the nature of the second argument when using multiselect controls, i.e., it could be an array.

:slight_smile:

that’s correct, array should be used for multicelect.
we will fix the docs, thanks.