Here is a simple script to get the values of the checked checkboxes and add them into an array.
CODE
<script>
var arr = new Array();
function fillArray(){
var str = "VALUES:{";
var cb = new Array();
var tags = document.getElementsByTagName("input");
for(var i=0; i<tags.length; i++){
if(tags[i].checked && tags[i].type == "checkbox"){
cb[cb.length] = tags[i].value;
if(cb.length > 1){
str += ", "+tags[i].value;
}
else{
str += ""+tags[i].value;
}
}
}
alert(str+"}");
return cb;
}
</script>
<input type="checkbox" value="test">
<input type="checkbox" value="Able">
<input type="button" value="BTN" onclick="arr=fillArray();" />
Here it is when we get rid of the string alerting:
CODE
<script>
var arr = new Array();
function fillArray(){
var cb = new Array();
var tags = document.getElementsByTagName("input");
for(var i=0; i<tags.length; i++){
if(tags[i].checked && tags[i].type == "checkbox"){
cb[cb.length] = tags[i].value;
}
}
return cb;
}
</script>
<input type="checkbox" value="test">
<input type="checkbox" value="Able">
<input type="button" value="BTN" onclick="arr=fillArray();" />
NOTICE - The function creates a new array and returns that array, you have to set the returned array to an array otherwise it is lost.
Hope that helps.