Click to See Complete Forum and Search --> : "collapsing" text in .NET


yaniv hanya
08-24-2004, 08:24 AM
i create a table during run time, using the "table", "row", and "cell" methods...

i want to show the first line of the subject, and when the user click it- to open the text. i know i should use javascript, so i used literal control in the tables cell's to hold the text.

what i tried to do is to add "<div id = 'text' style='displey:none'>" in the literal, and "onclick" method to the link button.

and then i used this function:
<script language="javascript">
function show ()
{
document.getElementById('text').style.display = "";
}
</script>


well, the problem is it is not working (the text is allways hides). what do i done wrong? are there is another (working) way to do it?

buntine
08-24-2004, 08:44 AM
Try using 'none' as "" is not a valid value.

<script language="javascript">
function show ()
{
document.getElementById('text').style.display = 'none';
}
</script>

Its DHTML, by the way ;)
Regards.

yaniv hanya
08-24-2004, 12:04 PM
and what should i use for showing the DIV?

Cstick
09-02-2004, 07:10 PM
I think buntine had the right idea with 'none'. If it were me though, I wouldn't use javascript. I would do something like this.

<%@ Page Language="VB" %>
<html>
<head>
<script language="vb" runat="server">
if text.visible = false then
text.visible = true
else
text.visible = false
end if
</script>
</head>
<body>
<div id="text" runat="server">some text</div>
</body>
</html>