Return to Snippet

Revision: 39706
at January 20, 2011 01:27 by danhanly


Initial Code
<script>
function checkBoxes(){
    var result, vals = [], checkBoxName =  document.forms['formName']['checkBoxName[]'];
    for(var i=0,elm;elm = checkBoxName[i];i++) {
        if(elm.checked) {
            vals.push(encodeURIComponent(elm.value));
        }
    }
    result = vals.join(', ');
}
</script>
<form name="formName">
    <input type="checkbox" name="checkBoxName[]" value="Value 1" />
    <input type="checkbox" name="checkBoxName[]" value="Value 2" />
    <input type="checkbox" name="checkBoxName[]" value="Value 3" />
    <input type="checkbox" name="checkBoxName[]" value="Value 4" />
    <input type="checkbox" name="checkBoxName[]" value="Value 5" />
    <input type="button" onClick="checkBoxes()" />
</form>

Initial URL

                                

Initial Description

                                

Initial Title
Processing Checkbox Group

Initial Tags
form, javascript, html, array

Initial Language
HTML