function read()
{

var numbers = new Array();

for (i = 0; i < field.length; i++)
    numbers[i] = document.test.checkboxName.value;






var counter=0;

//Let's print out the elements of the array.
for (counter=0; counter<numbers.length; counter++)
   document.write(numbers[counter] + "<br>");
}

I want to read the values of the checkboxs and store the vlaues into an array (there are more than 1 checkboxs) the form name is text and the names of the check box = checkboxname

any help would be appreciated as i dont know where i am going wrong

okay decided to do it in JSP

<html>
<h2>Numbers:</h2>

<form ACTION="index.jsp">
<input type="checkbox" name="id" value="0000"> bob<BR>
<input type="checkbox" name="id" value="1111"> john<BR>
<input type="checkbox" name="id" value="2222"> paulk<BR>
<input type="checkbox" name="id" value="3333"> roger<BR>
<input type="checkbox" name="id" value="4444"> marc <BR>
<input type="submit" value="Submit">
</form>
<%

String numbers[] = request.getParameterValues("id");
if (numbers != null && numbers.length != 0) {
out.println("You have selected: ");
for (int i = 0; i < numbers.length; i++) {
out.println(numbers[i]);
}
}
%>
</html>

For any one who is having similar trouble
got the tut from roseindia

you can manipulate form element's by simply icrementing it using the element propreties:

var chbVal = [];
for ( var x = 0; x < form.elements.length; x++ ) {

// checkbox ids can also be provided in replace of x varible.
// But if you have no other elements in the form asside from checkboxe, the x variable will do the job. 
   chbVal[x] = form.elements[x].value;
} // All the checkbox value is now stored in the chbVal array.

Thanks for the reply!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.