...

View Full Version : Show/hide tables



electrify77
05-20-2009, 10:10 PM
Hello,

I need help with the following scenario.

When someone arrives at my site I want certain tables to be displayed by default and others hidden. On each one of them I want there to be an image that will be a plus sign (eg. plus.png) for the hidden ones and a minus sign (eg. minus.png) for the shown ones.

When someone for example clicks on the plus.png image on a hidden table I want the table to show itself and the image to change to the minus.png one.

How can I do this?

Thank you!

ShadowIce
05-21-2009, 12:34 AM
Hello,

I need help with the following scenario.

When someone arrives at my site I want certain tables to be displayed by default and others hidden. On each one of them I want there to be an image that will be a plus sign (eg. plus.png) for the hidden ones and a minus sign (eg. minus.png) for the shown ones.

When someone for example clicks on the plus.png image on a hidden table I want the table to show itself and the image to change to the minus.png one.

How can I do this?

Thank you!

Try AJAX :)

electrify77
05-21-2009, 01:17 AM
Thanks but I know it's not AJAX... it's some JS I just don't know how exactly it works.

electrify77
05-21-2009, 09:19 PM
OK. Here's a short example I managed to scrape...


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>

<script language="javascript">
function show_box()
{
var id_Box = document.getElementById('box');

if (id_Box.style.display == 'none')
{
id_Box.style.display = 'block';
}
else
{
id_Box.style.display = 'none';
}
}
</script>

<p><a href="javascript:show_box();">LINK</a><p>&nbsp;</p>

<table id="box" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%">dfdfdfdfd</td>
</tr>
</table>
<p>&nbsp;</body></html>

The question is how can I make the Link be an image that changes - eg. when the table is shown the image should be minus.png and when the table is hidden it should be plus.png...

Any ideas?

electrify77
05-23-2009, 06:09 PM
Common - someone must know...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum