How do I programmatically set the value of a select box element using JavaScript?

You can use this function:

selectElement('leaveCode', '11')

function selectElement(id, valueToSelect) {    
    let element = document.getElementById(id);
    element.value = valueToSelect;
}

Leave a Comment

error code: 523