User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,469 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 8582 | Replies: 4
Reply
Join Date: Sep 2007
Posts: 3
Reputation: vignesh babu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vignesh babu vignesh babu is offline Offline
Newbie Poster

javascript - hide and display the div tag

  #1  
Oct 16th, 2007
Hello friends,

I got a problem while trying to hide and display the content within the <div> tag. Can anyone tell me how to do it. I tried with the following code its not working. i am using IE only and i want to work in IE only. Actually while loading the page the content should be in hide state.

function doInit() {
    	alert( "DoInit 1" );
    	element = document.getElementById('<divName>');
	element.style.display = 'none';
}
and

funtion doInit() {
document.getElementById(<divName>).style.visibility = 'hidden';
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,517
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: javascript - hide and display the div tag

  #2  
Oct 16th, 2007
JavaScript != Java

I have already asked the admins to move the thread.
Java Programmer and Sun Systems Administrator

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

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Mar 2007
Location: Israel
Posts: 16
Reputation: Shaffer is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
Shaffer Shaffer is offline Offline
Newbie Poster

Help Re: javascript - hide and display the div tag

  #3  
Oct 16th, 2007
Hello,
Firstly, it is really annoying that people keep posting JavaScript questions in the Java forum. They are so different.

Secondly, you got two things wrong:
1. Your <divName> is relavant for us. The function getElementById(), gets and element by it's ID, unlike the function getElementByName()!
2. In the second function, <divName> is not wrapped.

So, just change change your div:
From: <div name="<divName>"></div>
To: <div id="<divID>"></div>

The name doesn't matter, just pick one (you can make it id="Shaffer" for all your browser cares, just make only one. If more, your code will crash).

Anyhow,
this is how your page should look (add more stuff freely)...
<html>
<head>
  <script type="text/javascript">
funtion doInit() {
  document.getElementById('<divID>').style.visibility = 'hidden';
}
  </script>
</head>
<body onload="doInit()">
  <div id="<divID>"></div>
</body>

Notice the body onload="" since you wanted this to happen on page load.

Oh, and I see absolutely no reason for your first function to work!


Shaffer.
Reply With Quote  
Join Date: Sep 2007
Posts: 3
Reputation: vignesh babu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vignesh babu vignesh babu is offline Offline
Newbie Poster

Re: javascript - hide and display the div tag

  #4  
Oct 16th, 2007
Thank you,

And friends sorry for posting this javascript Q in java. It wont happen hereafter..
Reply With Quote  
Join Date: Mar 2007
Location: Israel
Posts: 16
Reputation: Shaffer is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
Shaffer Shaffer is offline Offline
Newbie Poster

Re: javascript - hide and display the div tag

  #5  
Oct 16th, 2007
Hello,
it's ok, don't worry about it.
Did it work?


Shaffer.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 5:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC