...

View Full Version : please help me with the change title and show/hide text java-script



hello20109876
05-07-2006, 12:25 PM
code is a little bit long (tens of lines), so I upload it to somewhere.

please click the link
http://www.syncedit.com/zzz/single.html
to see my question.

please ask if my question is not clear.

thanks

.

vwphillips
05-07-2006, 04:36 PM
<html>
<head>

<script>
//---------------------- code for swap text
var lst;
function swapText(p_element, p_text1){
if (!p_element.txt){ p_element.txt=p_element.innerHTML; }
menuitem=p_element.parentNode.getElementsByTagName('DIV')[0];
(p_element.innerHTML==p_text1)?p_element.innerHTML=p_element.txt:p_element.innerHTML=p_text1;
if (!menuitem){ return; }
menuitem.lk=p_element;
if (!menuitem.set){
menuitem.style.display='';
menuitem.set=true;
}
else {
menuitem.style.display='none';
menuitem.set=false;
}
// temove these lines if do not wish to clase lst
if (lst&&menuitem.set){ lst.style.display='none'; lst.set=false; lst.lk.innerHTML=lst.lk.txt}
lst=menuitem;
}



</script>

<style type="text/css">
.span0

{
font-size:18px;
font-weight:bold;
color:ff0000;
}
</style>


</head>

<body>
(Please see <b><font color="#008000">Explain</font></b> bellow first)

<br>
<br>
<span id="tempcontainer" class="mainDiv" style="visibility: hidden; position: absolute"></span>

<b>Part 1:</b> ----- click on red text <b>more</b> to change it (title) to <b>less</b>
<br>
<a>Click <span CLASS="Span0" onclick='swapText(this,"... less");'>... more</span> or visit ...
</a>
<br>
<br>
<b>Part 2:</b> ----- click on red text <b>more</b> bellow to show/hide hidden text
<br>
<a>
Click <span CLASS="Span0" onclick='swapText(this,"... less");'>... more</span> or visit ...
<div style="display:none;" state="0">
Go to <a href="http://www.google.com.au/" target="_new">google</a>
<br>
Go to <a href="http://www.google.com.au/" target="_new">google</a>

<br>
</div>
</a>
<br>
<br>
<b>Part 3:</b> ----- combination of Part 1 and Part 2: change and show/hide text.
<br>
but hidden text can not be shown - only change title is OK.
<br>
<a>Click <span CLASS="Span0" onclick='swapText(this,"... less");'>... more</span> or visit ...
<div style="display:none;" state="0">
Go to <a href="http://www.google.com.au/" target="_new">google</a>
<br>
Go to <a href="http://www.google.com.au/" target="_new">google</a>
</div>
</a>
<br>
<b>

</body>

</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum