You need to sign in to do that
Don't have an account?

Populating a multi selectlist using innerHTML
Hi
I'n trying to populate a multi selectlist using innerHTML but I guess I'm not doing the right thing.
This is what I'm doing where result is an array of strings (String[])
document.getElementById("{!$Component.thePage:theform:mainBlock:resultsBlock:theResultSection:sel1}").innerHTML = result
Can anyone help with an example of how it should be done?
Many thanks
This is a complete guess. I haven't updated Multi-selects with JS.
I know that the data is stored as a semi-colon separate string. Try doing that instead of your string array.
So if you want your multi-select to contain the values "Test1" and "Test2" and "Test3" you would assign the innerHtml to a value of "Test1;Test2;Test3"
Hi
Thanks for the advice, but it is still not working.
It seems I somehow have to insert an <option> into the <select> list but I'm not sure how I do it via javascript
Any advice?
two ways:
via newer DOM approach:
or the older Options object approach:
or if you want to insist on using innerHTML as you originally thought...
IE is known to have glitches/tag omission with innerHTML, so this one may be true for IE.
Thanks for the valuble tips :-)
I'll go and try it and see which method works best