Advertisement

05.08.2008 at 03:21AM PDT, ID: 23385526
[x]
Attachment Details

Expand/Colllapse div Works in IE not in firefox

Asked by eemani in JavaScript

Tags: Javascript, IE6, IE7, Firefox 2, safari2 and 3

The follwing code is working in ie. Not working in firefox.

This is a simple expand collapse div and changing the images(plus/minus). we can expand one div at a time. expanding other div will collapse all div and correspondingly change the images(plus/minus)

I think the firstchild is not working in firefox. Is there any other solution?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
<script language="javascript">
var openedObj = false;
function showhide(eImg,eDiv)
 {
    obj = document.getElementById(eDiv);
    if (obj.style.display == "none" || obj.style.display == "")
    {
          if(openedObj) {
			  openedObj.style.display = "none";
			  openedObj.parentNode.firstChild.src = '/images/plus.gif';
		  }
		   
          obj.style.display = "block";
		  eImg.src = '/images/minus.gif';
          openedObj = obj;
    }
    else
    {
          obj.style.display = "none";
     	  eImg.src = '/images/plus.gif';
		  
    }
  }
</script>  
<style type="text/css">
.showhidediv{
	display:none;
	border:1px solid #000;
	width:400px;
	height:200px;
}
</style>
 
<div id="details" class="itemsdiv">
	    <img src="/images//plus.gif" onclick="showhide(this,'tbl')" alt="Click here to expand" /><h4>Test1</h4>
        <div id="tbl" class="showhidediv">
          Details1Details1Details1Details1Details1Details1Details1 Details1Details1Details1Details1Details1Details1 Details1Details1Details1Details1Details1 Details1Details1Details1Details1Details1Details1 Details1Details1Details1Details1Details1 Details1Details1Details1Details1 Details1Details1Details1Details1 Details1Details1Details1Details1 Details1Details1Details1
        </div>
    </div>
   	<div id="items" class="itemsdiv">
        	    <img src="/images/plus.gif" class="showhideimg" onclick="showhide(this,'itmtbl')" alt="Click here to expand" /><h4>Test2</h4>
          <div id="itmtbl" class="showhidediv">
        	
             Details2Details2Details2Details2Details2 Details2Details2Details2Details2Details2Details2 Details2Details2Details2Details2Details2Details2 Details2Details2Details2Details2 Details2Details2Details2Details2Details2 Details2Details2Details2Details2Details2Details2Details2Details2 Details2Details2Details2Details2
          </div>
    </div>
   	<div id="distributers" class="itemsdiv">
        	    <img src="/images/plus.gif" class="showhideimg" onclick="showhide(this,'distritbl')" alt="Click here to expand" /><h4>Test3</h4>
   	    <div id="distritbl" class="showhidediv">
        Details3Details3Details3Details3Details3Details3 Details3Details3Details3Details3Details3 Details3Details3Details3Details3 Details3Details3Details3Details3Details3Details3 Details3Details3Details3Details3Details3 Details3Details3Details3Details3Details3 Details3Details3Details3Details3 Details3Details3Details3
          </div>
    </div>
[+][-]05.08.2008 at 04:23AM PDT, ID: 21523772

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: Javascript, IE6, IE7, Firefox 2, safari2 and 3
Sign Up Now!
Solution Provided By: d3stor
Participating Experts: 2
Solution Grade: B
 
 
[+][-]05.08.2008 at 12:27PM PDT, ID: 21527693

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 04:46AM PDT, ID: 21546016

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 08:11AM PDT, ID: 21547654

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 10:37PM PDT, ID: 21552544

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 10:14PM PDT, ID: 21570789

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628