|
Hi. Thanks for your replay.
This don't work like i need.
A have one page with a link to the popup window with the checkbox. When the popup window open, i select one um checkbox and return to initial page de value os this checkbox to a hidden field.
If the hidden field have some numbers, i passed than to the popup windows and the checkbox with this value is checked. A do this by:
function get_check_value()
//Retorna a string de valores checkados.
{
var c_value = ";";
for (var i=0; i < document.listagem.checkbox.length; i++)
{
if (document.listagem.checkbox[i].checked)
{
c_value = c_value + document.listagem.checkbox[i].value + ";";
}
}
return c_value;
}
function valor(lista)
//Checka as caixas a partir da lista de valores.
{
var elems = lista.split(";");
for(i in elems) {
var valor = elems[i];
if (valor != null && valor.length != 0) {
var checkboxes = document.forms['listagem'].elements['checkbox'];
for (j = 0; j < checkboxes.length; j++) {
var chk = checkboxes[j];
if (chk.value == valor){
chk.checked = true;
}
}
}
}
}
This works like i want, than i can't use de name os the checkbox to the new functionality.
But now i need check all the sub-checkbox when check a main checkbox in real time. But with this code, wen i check the checkbox A2, will check wrong B2.
This is my problem. I try this, but is wrong, because don't work's:
function checkGroup()
{
var checkboxes = document.forms['listagem'].elements['checkbox'];
var elemento = document.getElementById('checkbox');
if ((elemento.id.substring(10,9) == "1") && (elemento.checked) == true) {
var codigo = elemento.id.substring(9,8)
for (i=0; i < checkboxes.length; i++) {
var chk = checkboxes[j];
if (chk.id.substring(9,8) == codigo) {
chk.checked = true;
}
}
}
}
Thanks for you time and knowledge.
Pedro
|