Afiyf
05-31-2008, 09:52 PM
I'm having problems with a script that should present a link. When clicked, a paragraph of text is expanded. When clicked again it collapses.
This script is backward, it presents the paragraph and link. How do I hide the paragraph?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>4. Switch menu</title>
<script type="text/javascript">
<!--
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "none" ) {
el.style.display = 'none';
}else {
el.style.display = '';
}
}
//-->
</script>
</head>
<body>
<div id="par">
<p><a style="color:blue; cursor:pointer;" onclick="switchMenu('outpar');" title="Switch the Menu">4. Prepare the necessary code for the following scenario</a></p>
<div id="outpar">
<p>a. Create a link that displays a paragraph of text when clicked. <br />
When the link is clicked again the paragraph should disappear the paragraph should disappear <br />
the paragraph should disappear the paragraph should disappear the paragraph should disappear <br />
the paragraph should disappear the paragraph should disappear the paragraph should disappear<br />
the paragraph should disappear the paragraph should disappear. </p>
</div>
</div>
</body>
</html>
What did i do wrong here?
Afiyf
This script is backward, it presents the paragraph and link. How do I hide the paragraph?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>4. Switch menu</title>
<script type="text/javascript">
<!--
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "none" ) {
el.style.display = 'none';
}else {
el.style.display = '';
}
}
//-->
</script>
</head>
<body>
<div id="par">
<p><a style="color:blue; cursor:pointer;" onclick="switchMenu('outpar');" title="Switch the Menu">4. Prepare the necessary code for the following scenario</a></p>
<div id="outpar">
<p>a. Create a link that displays a paragraph of text when clicked. <br />
When the link is clicked again the paragraph should disappear the paragraph should disappear <br />
the paragraph should disappear the paragraph should disappear the paragraph should disappear <br />
the paragraph should disappear the paragraph should disappear the paragraph should disappear<br />
the paragraph should disappear the paragraph should disappear. </p>
</div>
</div>
</body>
</html>
What did i do wrong here?
Afiyf