Results 1 to 5 of 5

Thread: clear my confusion....

  1. #1
    Join Date
    Apr 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow clear my confusion....

    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....


  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    You cannot do this with HTML, but you can with JavaScript.
    Code:
    <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>
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Try the following code

    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>

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    What's wrong with mine?
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  5. #5
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Quote Originally Posted by tech_support View Post
    What's wrong with mine?
    I thought you've accounted one case.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •