Select all options in a multi-valued <select> - Node.js HTML

Node.js examples for HTML:Select Option

Description

Select all options in a multi-valued <select>

Demo Code

function selectAll(elementId) {
    var element = document.getElementById(elementId);
    len = element.length;/*from w  w  w.j  a  v  a  2 s.c  om*/
    if (len != 0) {
        for (i = 0; i < len; i++) {
            element.options[i].selected = true;
        }
    }
}

Related Tutorials