/    Sign up×
Community /Pin to ProfileBookmark

Table rows STILL won’t hide!!!!!!!!

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>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JPnycNov 10.2004 — 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.
Copy linkTweet thisAlerts:
@luvdairishauthorNov 10.2004 — 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)?



?
Copy linkTweet thisAlerts:
@JPnycNov 10.2004 — 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.
×

Success!

Help @luvdairish spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...