This problem seemed an obvious one. However, it took me 15 minutes to find the solution. So I thought I'd post it here.
Problem: you have a select box with multiple selection, and you want to add a button to be able to select all of the options programmatically.
Solution: the button will call the following JavaScript function:
var sel = document.getElementById('mySelect');
var len =sel.options.length;
for(var i=0; i<len; i++)
sel.options[i].selected= true;