Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

href toggle showing and hiding text

Status
Not open for further replies.

fcoomermd

Programmer
Joined
Nov 20, 2002
Messages
218
Location
CA
this is what I would like... I want a link that calls a function that toggles between visible and hidden for a span tag... I can get one, but not the other.
This is what I have...
<HTML>
<HEAD>
<script type=text/javascript>

function toggleT(_w) {
alert(_w);
if (document.all) {
// is IE


if (&quot;document.all.&quot;+_w+&quot;.style.visibility='hidden';&quot;) {
alert(&quot;visible&quot;)
eval(&quot;document.all.&quot;+_w+&quot;.style.visibility='hidden';&quot;);
}else{
alert(&quot;hidden&quot;);
eval(&quot;document.all.&quot;+_w+&quot;.style.visibility='visible';&quot;);
}


} else {
// is NS?
if (_h=='s') eval(&quot;document.layers['&quot;+_w+&quot;'].visibility='show';&quot;);
if (_h=='h') eval(&quot;document.layers['&quot;+_w+&quot;'].visibility='hide';&quot;);
}
}

</script>
</HEAD>
<BODY>

Visible <a href=&quot;#&quot; onClick=&quot;toggleT('divt1')&quot;>Show</a>

<span id=&quot;divt1&quot; style=&quot;visibility:hidden;position:relative;top:0;left:0&quot;>
....
</form>
</span>


</BODY>
</HTML>

//cant get pass this now..
any help?
FC
 
This is what I am using to toggle div. :

<script language=&quot;Javascript&quot;>
var j = 1;
var first = 1;
var last = 1;
function mkdivv(num) {
mkdivh(last);
document.getElementById(&quot;layer&quot;+num).style.visibility = 'visible';
last = num;
j++
}
function mkdivh(num) {
document.getElementById(&quot;layer&quot;+num).style.visibility = 'hidden';
}
function defdivv() {
document.getElementById(&quot;layer&quot;+last).style.visibility = 'hidden';
document.getElementById(&quot;layer1&quot;).style.visibility = 'visible';
}
</script>
This works in Net7.0 & IE....
I've not tried this with spans, I don't see a diff.

Good Luck,

2b||!2b
 
still cant get it going... i can only have one link...
and it toggles between showing and hiding.
FC
 
Seems like you are going to have to figure out
what event will trigger the show/hide events.

onMouseOver, onMouseOut, onClick, etc.

You'll have to figure out what action to make it visible
then
What action to make it hidden....

2b||!2b
 
Hers's a thought, you could include a counter
that would count the clicks of the link

<a href=&quot;javascript:showhide()&quot;>Link</a>

Then on every even number hide the span like:
var clk = 1;//START THIS NUMBER ACCORDING TO SHOW OR HIDE
function showhide() {
if(clk % 2 == 0) //IF EVEN NUMBER
{ hide code }
else { show code }//IF ODD NUMBER
clk++;
}



2b||!2b
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top