473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Figuring out Hide/Unhide mode, in IE and Mozilla

Hello all,

I'm a php developer. I have been using a very simple script to
hide/unhide divs in my script:

function DisplayI(obj)
{
obj.style.display=("none"==obj.style.display? "block" : "none");
}

the Div tag, looks like this:
<div id="blabla" style='display:hidden;'>

the ID of the Div is being compiled by a php script linked to a
Database (therefore, all DIVs get different ids).

It works perfectly in I.E, but in mozilla (firefox and netscape) it
doesn't.
If I change "display:hidden" to "display:block", it shows them open
completely (without hiding) throughout mozilla and I.E together.

I'm looking for a script that hide and unhides my divs and works in a
crossbrowser environment.
I've seen codes to solve the crossbrowser thing, but all of them
seperated "hidediv" and "showdiv" to two functions, and I need them
unified - the code to figure out if the div is shown and hide it, and
the other way around.

Can anyone please help me with this?
Thanks a lot!

~mooey

Sep 26 '05 #1
5 4748
On 26 Sep 2005 00:41:24 -0700, mooeypoo wrote:
function DisplayI(obj)
{
obj.style.display=("none"==obj.style.display? "block" : "none"); ^^^^ }

the Div tag, looks like this:
<div id="blabla" style='display:hidden;'>


<div id="blabla" style='display:none'>

"hidden" is value of visibility style's attribute.

--
~ "FINARMENTE LI SFRATTATI AVRANNO UN TETTO SULLA TESTA!
....però tirato ammodino, un tegolo pe' vorta.." (Il vernacoliere)

Sep 26 '05 #2
mooeypoo wrote:
Hello all,

I'm a php developer. I have been using a very simple script to
hide/unhide divs in my script:

function DisplayI(obj)
{
obj.style.display=("none"==obj.style.display? "block" : "none");
}

the Div tag, looks like this:
<div id="blabla" style='display:hidden;'>


<div id="blabla" style='display:none;'> // note "display" property.
function DisplayI(id){
var obj;
if(obj=document.getElementById(id)){
obj.style.display=("none"==obj.style.display?"":"n one");
return;
}
//if you arrive here, obj doesn't exist.
}

[snip]
Mick
Sep 26 '05 #3
I have done all of that (changed display to none, and tried your code)
but now it doesnt' work in I.E aswell :( won't open my divs.

It doesn't even show an error, it just doesn't show my div in I.E or
Mozilla Firefox.

Ideas? :(

Thanks !

~mooey

Sep 26 '05 #4
ASM
mooeypoo a écrit :
I have done all of that (changed display to none, and tried your code)
but now it doesnt' work in I.E aswell :( won't open my divs.

It doesn't even show an error, it just doesn't show my div in I.E or
Mozilla Firefox.

Ideas? :(


re strat from beginning ...

<html>
<p><button onclick="mooey('poo');">yes no</button>
<div id="poo" style="display: none;height:150px;">
<h1>it is not a good idea</h1>
<p>Why ?
<p>Because without JS you'll can never see this div ...
</div>
<h2> Oh what a so terrific YoYo effect !</h2>

<script type="text/javascript">
function mooey(aDiv) {
var D = document.getElementById(aDiv).style;
D.display = D.display==''? 'none' : '';
}
</script>
</html>

--
Stephane Moriaux et son [moins] vieux Mac
Sep 26 '05 #5
Stephane,

thanks, but it still doesn't work in Firefox. :(

~mooey

Sep 28 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ian Shere | last post by:
I have a disclaimer page prior to a visitor going to my FAQ page. I want to hide the link which normally appears in the status bar from visitors seeing it. I am using the following code which...
5
by: jeff | last post by:
Hello, I am coding a web application to be used on an internal Intranet. I have already coded a menubar for the application using DHTML. I want to get rid of the standard menubar in Mozilla...
12
by: deko | last post by:
Is there any way to work around the blank space created by hidden divs? I'm trying to use a relatively postioned divs with show/hide behaviors to annotate an image. The divs show/hide...
9
by: Wang, Jay | last post by:
I try to group several rows in a table into a div and show/hide them by click on a button somewhere with a javascript link. When clicked, the link will toggle the style of the div section's style...
3
by: toodi4 | last post by:
I'm using a javascript that hides and unhides text based on a button click. It works great across static fields on a form. The problem I have is that I'm trying to hide and unhide various fields...
3
by: =?Utf-8?B?aWxy?= | last post by:
Hi All I am developing an vb 2005 winforms application that connects to a database and displays a datagridview of the data. A user can select and then edit, or create a new entry by opening a...
1
by: Simon | last post by:
Dear reader, In a datasheet form you have the possibility to hide or unhide columns. But in case the datasheet form is a sub-form this functionality is not longer available.
4
by: somasekhar | last post by:
Does anyone know how to have a user click a checkbox to unhide a editfield Unclick of the checkbox would hide it again. There is an example of html file on the Javascript .But I want hide and unhide...
6
by: Ralph | last post by:
Hi, I was reading effictive C++ and some other books again and they all tell you about hiding implementation details (proxy/pimpl/inheritance) but they never really explain when to use it. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.