Forum Moderators: open
It was trying to update a JavaScript's Function, but of the mistake.
The function:
------------------------------------------
function Mark(which){
if (eval("document.form." + which + ".checked")){
eval("tr" + which + "getElementById(" + which + ").style.background = '#D2E9FF'")
} else {
eval("tr" + which + "getElementById(" + which + ").style.background = ''");
if((which!= 'principal')&&(document.form.principal.checked)) {
document.form.principal.checked = false;
Mark('principal')
}
}
}
------------------------------------------
It is giving mistake in the two lines that contains getElementById.
I want to use him because W3C only been worth if it has this function.
sorry my english.
thanks.
Do not worked. He selected only the table that has checkbox and is not working on Firefox. I am going to pass the whole code for you see.
--------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CheckBox - Test</title>
<script type="text/javascript">
function SelectAll() {
for (var i=0;i<document.form.elements.length;i++) {
var x = document.form.elements[i];
if (x.id == 'principal') {
x = document.form.principal.checked;
}
if(x.type == 'checkbox') {
x.checked = document.form.principal.checked;
Mark(x.id)
}
}
}
function Mark(which){
if (eval("document.form." + which + ".checked")){
window.document.getElementById( which ).style.background = '#D2E9FF';
} else {
window.document.getElementById( which ).style.background = '';
if((which!= 'principal')&&(document.form.principal.checked)) {
document.form.principal.checked = false;
Mark('principal')
}
}
}
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form name="form" method="post" action="">
<table width="100%" cellspacing="2">
<tr id="trprincipal">
<td width="2%"><input type="checkbox" id="principal" name="principal" onClick="SelectAll()" /></td>
<td width="98%"> </td>
</tr>
<tr id="trq05">
<td><input onClick="Mark('trq05')" type="checkbox" id="q05" name="aaaa" value="001" /></td>
<td> </td>
</tr>
<tr id="trq02">
<td><input onClick="Mark('trq02')" type="checkbox" id="q02" name="bbb" value="001" /></td>
<td> </td>
</tr>
<tr id="trq03">
<td><input onClick="Mark('trq03')" type="checkbox" id="q03" name="ccc" value="001" /></td>
<td> </td>
</tr>
<tr id="trq04">
<td><input onClick="Mark('trq04')" type="checkbox" id="q04" name="ddd" value="001" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
----------------------------------------------------
Copy and paste that code and see. In the IE works partially. He does not select for tag <tr></tr> all. And in the firefox does not work.
Thanks.