/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Expand collapse tbody not working in IE

[CODE]
function getItem(id)
{
var itm = false;
if(document.getElementById)
itm = document.getElementById(id);
else if(document.all)
itm = document.all[id];
else if(document.layers)
itm = document.layers[id];

return itm;
}

function toggleTable(id)
{
itm = getItem(id);
if(!itm)
return false;
if(itm.style.display == ‘none’){
itm.style.display = ”;
img = getItem(‘showhideimage’);
img.src = “img/collapse.png”;
}else {
itm.style.display = ‘none’;
img = getItem(‘showhideimage’);
img.src = “img/expand.png”;
}
return false;
}
[/CODE]

[code=html]
<table class=”list” cellspacing=”0″ cellpadding=”0″ border=”0″ style=”width: 100%;”>
<thead>
<tr>
<th class=”head” colspan=”4″>
<img id=”showhideimage” onclick=”toggleTable(‘templates’);” alt=”Show/Hide Reports” src=”img/collapse.png”/>
Available Reports
</th>
</tr>
<tr>
<th align=”left”>Report Name</th>
<th align=”left” width=”20%”>Last Changed</th>
<th align=”left” width=”10%”>Options</th>
</tr>
</thead>
<tbody id=”templates” style=””>
<tr class=”odd”>
<td align=”left”> Timesheet</td>
<td align=”left” width=”20%”>2008/09/30 11:30AM</td>
<td align=”center” width=”10%”>
<a href=”#”>
<img onclick=”xajax_generateReport(22);” title=”Generate Report” src=”img/run.png”/>
</a>
</td>
</tr>
</tbody>
</table>
[/code]

This code works fine in FF but in IE it hides the whole table and not just the tbody.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@voidvectorNov 24.2008 — Not sure which version of IE are you using, your code works find under my IE.
Copy linkTweet thisAlerts:
@kloon_zaauthorNov 24.2008 — Not sure which version of IE are you using, your code works find under my IE.[/QUOTE]

Using IE7, it does hide it but then i cant expand it again because the it hides the whole table and not just the tbody.
Copy linkTweet thisAlerts:
@kloon_zaauthorNov 24.2008 — I found my problem i had a form with same name as the id and for some reason IE collapsed/expanded the form and not the table.
×

Success!

Help @kloon_za 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.3,
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,
)...