Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Show hidden table by clicking a cell in another table


Message #1 by william.sze@s... on Tue, 19 Feb 2002 15:50:24 -0500

Hi all,



I have an asp page with two tables.



Table1 consists of 3 rows. I am able to have the table2 hidden when page

onload. I would like to show table2 by clicking one of the cell in table1.



I think it works like the onbeforeprint as on many articles, but I just

could not figure out the onclick event inside a table.



Please give me some hint.



Thanks

William



Message #2 by william.sze@s... on Tue, 19 Feb 2002 19:05:24 -0500

Hi all,



Haven't got any reply yet, but I almost figure it out except 2 display

issues.



My asp code as follows:



<html>

<head>..............</head>

<script language="javascript" >

function ShowAll( ){

var remove_el=document.all.remove

remove_el[i].style.display=''

}



function HideAll( ) {

var remove_el=document.all.remove

remove_el[i].style.display='none'

}



function Show(argDiv ){

if (argDiv=='A'){ var remove_el=document.all.TableA; }

if (argDiv=='B'){ var remove_el=document.all.TableB; }

if (argDiv=='C'){ var remove_el=document.all.TableC; }

for (i=0;i<remove_el.length ; i++)

remove_el[i].style.display=''

}



function Hide(argDiv){

if (argDiv=='A'){ var remove_el=document.all.TableA; }

if (argDiv=='B'){ var remove_el=document.all.TableB; }

if (argDiv=='C'){ var remove_el=document.all.TableC; }

for (i=0;i<remove_el.length ; i++)

remove_el[i].style.display='none'

}

</script>



<body onload="HideAll( )">

<%

....

'create Table1

</table>

...

<td><a href="javascript:Show('A');">display A</a></td></tr>

...

<td><a href="javascript:Show('B');">display B</a></td></tr>

...

<td><a href="javascript:Show('C');">display C</a></td></tr>

</table>

....

<a href="javascript:ShowAll( );">show all</a>

.............

'create TableA

<div id="TableA">

<table id="remove">

.........

<th><a href="javascript:Hide('A');">QtyA</a></tr>

.........

</table>

</div>

........

'create TableB

<div id="TableB">

<table id="remove">

.........

<th><a href="javascript:Hide('B');">QtyB</a></tr>

.........

</table>

</div>



.......

'create TableC

<div id="TableC">

<table id="remove">

.........

<th><a href="javascript:Hide('C');">QtyC</a></tr>

.........

</table>

</div>



%>





When I first load it,

1.Table1 display successfully;

2. TableA, B, C all hidden;



Click on display A,

1. does not display TableA



Click on display B,

1. does not display  TableB



Click on display C

1. does not display  TableC



Click on show all,

1. display all 3 TableA, B, C



Click on QtyA,

1. hide TableA



Click on QtyB,

1. hide TableB



Click on QtyC

1. hide TableC



Further Click on show all,

1. does not display the 3 TableA, B, C



Further Click on display A,

1. show TableA



Further Click on display B,

1. show  TableB



Further Click on display C

1. show  TableC



Would anyone help to find out:

why the first time click on display A or display B or display C do not show

the corresponding table;

why the show all only show the 3 tables once - after the first time display

it won't show the 3 tables again;



Thanks in advance,

William





                                                                                                                   

                    William Sze                                                                                    

                                         To:     "ASP Web HowTo" <asp_web_howto@p...>                      

                    02/19/2002           cc:                                                                       

                    03:50 PM             Subject:     Show hidden table by clicking a cell in another table        

                                         (Document link: William Sze)                                              

                                                                                                                   







Hi all,



I have an asp page with two tables.



Table1 consists of 3 rows. I am able to have the table2 hidden when page

onload. I would like to show table2 by clicking one of the cell in table1.



I think it works like the onbeforeprint as on many articles, but I just

could not figure out the onclick event inside a table.



Please give me some hint.



Thanks

William








  Return to Index