•
•
•
•
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
![]() |
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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.
and
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';
}funtion doInit() {
document.getElementById(<divName>).style.visibility = 'hidden';
} JavaScript != Java
I have already asked the admins to move the thread.
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
----------------------------------------------
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
•
•
Join Date: Mar 2007
Location: Israel
Posts: 16
Reputation:
Rep Power: 2
Solved Threads: 1
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)...
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.
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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Mouse Over ToolTip Help (JavaScript / DHTML / AJAX)
- Order Of DIV Tag And SEO (Search Engine Optimization)
- How to get the javascript objects in html body tag (JavaScript / DHTML / AJAX)
- preload a javascirpt file before you can click on a hyperlink (JavaScript / DHTML / AJAX)
- visibility & disable (JavaScript / DHTML / AJAX)
- mozilla firefox problem with text in div tag (HTML and CSS)
- <script language=\"javascript\"> Display problem with PHP & MYSQL (PHP)
- Hide/display filed on a new row - not a trivial task (JSP)
- Need help in design and javascript code for Dynamic form (JavaScript / DHTML / AJAX)
- XHTML and javascript 'setInterval' (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Populating Select Box w/ Passed In Value?
- Next Thread: How to copy and past external javascript



Linear Mode