Log in

View Full Version : clear my confusion....



sweetboy
04-24-2007, 06:56 AM
hi all,

i am designing web page using html.i'm new to html.
in that i have links and contents..
i am using <div> and <a> tag also. if i click the link ,the content should be displayed in the <div> space .within the same page...

can anyone give me the solution for this?
reply soon....

:confused: :confused:

tech_support
04-24-2007, 07:00 AM
You cannot do this with HTML, but you can with JavaScript.


<div id="mydiv" style="display:none;">Hello</div>
<a href="javascript:displayDiv('mydiv')">Display Hello</a>
<script type="text/javascript">
function displayDiv(divId) {
document.getElementById(divId).style.display = "block"
}
</script>

codeexploiter
04-24-2007, 07:40 AM
Try the following code



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function insertContent(sContent,id) {
document.getElementById(id).innerHTML = sContent;
return;
}

function displayTheDiv(id)
{
document.getElementById(id).style.display = "block";
return;
}

window.onload = function() {
document.getElementById('second').style.display = "none";
}

</script>
</head>
<body>
<a href="#" onclick="javascript: insertContent('This is a test','first');">Click To Insert Content</a>
<a href="#" onclick="javascript: displayTheDiv('second');">Click To Display Div</a>
<p>
<div id="first"></div>

<div id="second">Already hidden content here</div>
</p>
</body>
</html>

tech_support
04-24-2007, 07:41 AM
What's wrong with mine?

codeexploiter
04-24-2007, 08:22 AM
What's wrong with mine?

I thought you've accounted one case.