Click to See Complete Forum and Search --> : Table rows STILL won't hide!!!!!!!!


luvdairish
11-10-2004, 03:10 PM
I have been working on this stupid function (hideRows)for hours. My variable "id" get's it's value. The variable "e2" does not. It's null. PLEASE HELP!!!

Here is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Untitled Document</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<SCRIPT type=text/javascript>
<!--//
function hideShow(element){
var el = document.getElementById(element);
el.style.display = (el.style.display == 'none') ? 'block' : 'none';


}
//-->

<!--//
function hideRows(){

for (i = 0; i <= 5; i++){
id = ('table'+i);
document.write(id);
var e2 = document.getElementById(id);
document.write("<br>"+e2);
e2.style.display='none';
document.write("<br>"+i);
}


}
//-->
</SCRIPT>

</HEAD>

<BODY onload="hideRows()" >

<FORM name=form1 action="" method=post>
<TABLE width="75%" border=0>
<TBODY>
<TR>
<TD width="6%"><INPUT onclick="hideShow('table1')" type=checkbox
value=1 name=check_1></TD>
<TD width="94%">All hardware and software is listed</TD></TR>
<TR>
<TD>&nbsp;</TD>
<TD>
<TABLE id=table0 borderColor=#ff0000 cellSpacing=0 cellPadding=0
width="40%" border=0>
<TBODY>
<TR>
<TD><INPUT type=radio value=checkbox name=radio> Issue</TD>
<TD><INPUT type=radio value=checkbox name=radio> Minor Issue</TD>
<TD><INPUT type=radio value=checkbox name=radio> Ok</TD>
</TR>
<TR>
<TD align=middle colSpan=3><INPUT size=50></TD>
</TR>
<TR>
<TD>&nbsp</TD>
</TR>
</TBODY>
</TABLE>
</TD></TR>
<TR>
<TD width="6%"><INPUT onclick="hideShow('table2')" type=checkbox
value=1 name=check_2></TD>
<TD width="94%">ID number matches manufacturer's request and chip
label</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>
<DIV align=left></DIV>
<TABLE id=table1 borderColor=#ff0000 cellSpacing=0 cellPadding=0
width="40%" border=0>
<TBODY>
<TR>
<TD><INPUT type=radio value=checkbox name=radio2> Issue</TD>
<TD><INPUT type=radio value=checkbox name=radio2> Minor Issue</TD>
<TD><INPUT type=radio value=checkbox name=radio2> Ok</TD>
</TR>
<TR>
<TD align=middle colSpan=3><INPUT size=50></TD>
</TR>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD></TR></TBODY></TABLE>
<P>&nbsp;</P></FORM></BODY></HTML>

JPnyc
11-10-2004, 03:13 PM
You're using getElementById yet none of your rows has an id. How is the JS supposed to know which you want to hide? And remember, ID's must be UNIQUE. And please don't post more than 1 thread about the same topic. Thanks.

luvdairish
11-10-2004, 03:30 PM
Sorry, my function name is hideRows, but it's actually the table id that is named so it can be hidden (I should have called it hideTable). My ID's are unique. One is table0 and the other table1.

Thanks for your prompt responses to this, and my other post. Sorry for the additional post. Next time I'll keep it under the same topic.

Any ideas what my problem could be (besides my poor programming)?



:(

JPnyc
11-10-2004, 05:05 PM
Yeah, I know exactly where the problem is. When you use getElementById('idOfTheElementMustGoHere')if you don't put the ID name of the element there, JS just says "huh? which one?" and then does nothing. You have 'element' which is not the id of any of your tags.