var total = 0;
for (var i = 0; i < document.form_name.style.length; i++)
{
for (var x = 0; x < document.form_name.style[i].length; x++)
{
if (document.form_name.style[i][x].checked)
{
total += 1;
}
}
}
function count_calc()
{
var total = 0;
for (var i = 0; i < document.bar.length; i++)
{
if (document.bar.elements[i].type == 'checkbox')
{
total += 1;
}
}
}
Because as far as I know such name 'style[3563447][2]' doesn't mean you get an array in JS. We were discussing relative problems some threads ago.
Every form has elements property that is an associative array of all the inputs in the form.
document.form.input_name just an alias so it should be an input, not the array.
Also if you working with forms you can check this page - http://developer.mozilla.org/en/docs/DOM:form
I think it will be useful
form_name.style won't exist (as an element of the form.) Each of the names is unique therefore not an iterable array. You'll need to iterate the element list of the form like Gente shows.
Ok, well that works ok, but there are still a few features I would like to add and I thought using the array indexes would be the best route. I believe this is why I am not fond of Javascript.
What would be the best way to ensure that style [3563447][2] and [3563448][2] cannot both be checked at the same time. I can't use radios and it's already done server side. I would like to add this on the client side as well.