473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Show/hide TR

Hi There,

I would like to show details in another (hidden) TR. It should look like
something like on an image I have found wich illustrates it exactly is I
want:

http://otn.oracle.com/tech/blaf/spec...ils_white1.gif

Is there a sample code to do this? I allready could change the status from a
hidden tr using:

function toggle(theElem){
document.getElementById(theElem).style.display =
(document.getElementById(theElem).style.display == 'none')?'':'none';
}

But I would like a (sample)code, which changes the + and - and the Hide/Show
text. Any help appreciated.
Jul 20 '05 #1
1 12611
"Roger Godefroy" <godefroy@(no spam)home.nl> wrote in message
news:bk**********@news3.tilbu1.nb.home.nl...
Hi There,

I would like to show details in another (hidden) TR. It should look like
something like on an image I have found wich illustrates it exactly is I
want:

http://otn.oracle.com/tech/blaf/spec...ils_white1.gif
Is there a sample code to do this?


Well, tested on IE6 and Mozilla, this should works:

<html>
<head>
<script type="text/javascript">
function appendRow(after){
var newrow = document.createElement("TR");
var newcell = newrow.appendChild(document.createElement("TD"));
newcell.setAttribute("colSpan", "7");
newcell.innerHTML = "WHATEVER YOU WANT";
try{
after.parentNode.insertBefore(newrow,after.nextSib ling);
}
catch(e){
after.parentNode.appendChild(newrow);
}
}
function removeRow(thisRow){
thisRow.parentNode.removeChild(thisRow.nextSibling ,true);
}
function toogle(evt){
var evt = evt || window.event;
var obj = evt.target || evt.srcElement;
if (!obj.expanded){
obj.firstChild.nodeValue = "Hide";
appendRow(obj.parentNode);
}
else{
obj.firstChild.nodeValue = "Show";
removeRow(obj.parentNode);
}
obj.expanded = !obj.expanded;
}

function init(){
var tds = document.getElementsByTagName("TD");
for (var i=0; i<tds.length; i++){
if (tds[i].className == "sh"){
tds[i].expanded = false;
if (tds[i].addEventListener)
tds[i].addEventListener("click",toogle,false)
else if (tds[i].attachEvent)
tds[i].attachEvent("onclick",toogle);
else tds[i].onclick = toogle;
}
}
}
onload=init;
</script>
<style type="text/css">
..sh{
color:blue;
cursor:pointer;
text-decoration:underline;
}
</style>
</head>

<body>
<table border=1>
<thead>
<tr>
<th>Details</th>
<th>Line</th>
<th>Item Description</th>
<th>Unit</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6" align="right">Total</td>
<td>1,200.00</td>
</tr>
</tfoot>
<tbody>
<tr>
<td class="sh">Show</td>
<td>1</td>
<td>Some description</td>
<td>134</td>
<td>76</td>
<td>100</td>
<td>300</td>
</tr>
<tr>
<td class="sh">Show</td>
<td>2</td>
<td>Some description</td>
<td>12</td>
<td>765</td>
<td>100</td>
<td>300</td>
</tr>
<tr>
<td class="sh">Show</td>
<td>3</td>
<td>Some description</td>
<td>32</td>
<td>43</td>
<td>100</td>
<td>300</td>
</tr>
<tr>
<td class="sh">Show</td>
<td>4</td>
<td>Some description</td>
<td>34</td>
<td>76</td>
<td>100</td>
<td>300</td>
</tr>
</tbody>
</table>
</body>
</html>

HTH,

Vjekoslav
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
5
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
3
by: alex | last post by:
I'd like to have a show/hide widget on my web site, kind of like "show details" / "hide details" in Google Groups. Is there a tutorial explaining how to make them? Google's is a bit complex and...
0
by: Efkas | last post by:
I have a full custom application with some widged extending Controls like Label and PictureBox. I build a menu with these widgets. When I click on one of them, it calls a function to display...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.