Forum Moderators: open

Message Too Old, No Replies

Expand/Collapse Specifics

Expand Collapse Paragraphs

         

swy000

9:48 am on Apr 7, 2006 (gmt 0)

10+ Year Member



Hey everyone,

This is my first post. My name is Sam. I read around the website and i got some good help on this but im still lost in something i cant manage to figure out.

How do you make a paragraph expandable/collapsable using a hyperlink in the end that changes with the state of the paragraph (expanded vs collapsed)

Take this a visual example of what i mean:
State1
This is a test paragraph in which if you click[expand]
(once u click the hyperlink "expand post" it will change to State2)

State2
This is a test paragraph in which if you click on the expand hyperlink it will become a full paragrah [Collapse]
(once u click the hyper link "collapse" it will go back to the State1)

Thanks you for the help...

Sam

Moby_Dim

12:52 pm on Apr 7, 2006 (gmt 0)

10+ Year Member



<head>
<script language="JavaScript" type="text/javascript">
<!--
var flag = 0;
function change() {
var par = new getObj('templ');
if(flag) {
par.obj.innerHTML = 'This is a test paragraph in which if you click[expand] (<a href="javascript:void(0)" onclick="change()">once u click the hyperlink "expand post" it will change to State2</a>)';
flag = 0
}
else {
par.obj.innerHTML = 'This is a test paragraph in which if you click on the expand hyperlink it will become a full paragrah [Collapse] (<a href="javascript:void(0)" onclick="change()"> once u click the hyper link "collapse" it will go back to the State1</a>)';
flag = 1
}
return false
}

// the following function's taken from QuirksMode website
function getObj(name) {
var o = 'this.obj = document.';
var s = 'this.style = document.';
if (document.getElementById) {
eval(o + 'getElementById(name);');
eval(s + 'getElementById(name).style;');
}
else if (document.all) {
eval(o + 'all[name];');
eval(s + 'all[name].style;');
}
else if (document.layers) {
eval(o + 'layers[name];');
eval(s + 'layers[name];');
}
}
//-->
</script>
</head>
<body>
<p id="templ">This is a test paragraph in which if you click[expand] (<a href="javascript:void(0)" onclick="change()">once u click the hyperlink "expand post" it will change to State2)</a></p>
</body>

swy000

12:50 am on Apr 8, 2006 (gmt 0)

10+ Year Member



Moby_Dim: thank you very much.... that was perfect. I was going about the wrong way completly...
thanks again!

sam

Moby_Dim

6:01 am on Apr 8, 2006 (gmt 0)

10+ Year Member



Welcome to WebmasterWorld, Sam.

swy000

8:06 am on Apr 9, 2006 (gmt 0)

10+ Year Member



thnx Moby!