...

View Full Version : show/hide + change text



angiras
10-14-2003, 01:51 PM
how can I do ? :

<script type="text/javascript">
function SH(me,id)
{
if(document.getElementById(me).innerHTML='Hide')
{
document.getElementById(me).innerHTML='Show';
document.getElementById(id).style.display='none';
}
else
{
document.getElementById(me).innerHTML='Hide';
document.getElementById(id).style.display='block';
}
}
</script>
</head>
<body>
<a href="#" onclick="SH(this,'S_H')">Show</a>
<div id="S_H" style="display:none;">ok</div>
</body>



in a very esthetic way :-))

thank you

beetle
10-14-2003, 02:57 PM
I'll explain my revision if you want. If you can figure it out w/o my explanation, even better!


<script type="text/javascript">
function SH( me, id )
{
var you = document.getElementById( id );
if( me.innerHTML == 'Hide' )
{
me.innerHTML = 'Show';
you.style.display = 'none';
}
else
{
me.innerHTML = 'Hide';
you.style.display = 'block';
}
}
</script>
</head>
<body>
<span onclick="SH(this,'S_H')">Show</span>
<div id="S_H" style="display:none;">ok</div>
</body>

angiras
10-14-2003, 03:27 PM
perfectissimo, ca marche ! wunderbar !

it works !


I have change it in that way :

---------------------------------------------

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>titre</title>
<script type="text/javascript">
function SH(me,id,show,hide)
{
var you = document.getElementById( id );
if( me.innerHTML == hide )
{
me.innerHTML = show;
you.style.display = 'none';
}
else
{
me.innerHTML = hide;
you.style.display = 'block';
}
}
</script>
</head>
<body>
<form id="MainForm">
<span onclick="SH(this,'S_H','Open','Close');">Open</span>
<div id="S_H" style="display:none;">ok</div>
</form>
</body>
</html>

-----------------------------------------------

thank_you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum