/    Sign up×
Community /Pin to ProfileBookmark

Expand & Collapse not working

This is my first time doing this, and I used [URL=”http://support.internetconnection.net/CODE_LIBRARY/Javascript_Collapse_Expand.shtml”]this[/URL] example… but it’s not expanding & collapsing for me. Here’s what I have:

[B]Head:[/B]

[code=php]<script language=”JavaScript” type=”text/JavaScript” src=”js/collapse_expand_single_item.js”></script>
[/code]

[B]Body:[/B]

[code=html]<img src=”img/u.gif” name=”imgfirst” width=”9″ height=”9″ border=”0″ >
<a href=”#first” onClick=”shoh(‘first’);” >Customer Support</a>

<div style=”display: none;” id=”first” >
With its friendly solutions-oriented approach, our timely and knowledgeable Technical Support Staff are completely at your disposal. Our Support Technicians are highly trained on the inner workings of the Internet and its associated technologies. Combined with effective troubleshooting techniques, we can quickly identify and resolve technical issues whether they are on our end or on the client end. </div>
[/code]

[B]The JS script:[/B]

[code=php]*/

imgout=new Image(9,9);
imgin=new Image(9,9);

/////////////////BEGIN USER EDITABLE///////////////////////////////
imgout.src=”img/u.gif”;
imgin.src=”img/d.gif”;
///////////////END USER EDITABLE///////////////////////////////////

//this switches expand collapse icons
function filter(imagename,objectsrc){
if (document.images){
document.images[imagename].src=eval(objectsrc+”.src”);
}
}

//show OR hide funtion depends on if element is shown or hidden
function shoh(id) {

if (document.getElementById) { // DOM3 = IE5, NS6
if (document.getElementById(id).style.display == “none”){
document.getElementById(id).style.display = ‘block’;
filter((“img”+id),’imgin’);
} else {
filter((“img”+id),’imgout’);
document.getElementById(id).style.display = ‘none’;
}
} else {
if (document.layers) {
if (document.id.display == “none”){
document.id.display = ‘block’;
filter((“img”+id),’imgin’);
} else {
filter((“img”+id),’imgout’);
document.id.display = ‘none’;
}
} else {
if (document.all.id.style.visibility == “none”){
document.all.id.style.display = ‘block’;
} else {
filter((“img”+id),’imgout’);
document.all.id.style.display = ‘none’;
}
}
}
}[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@justinbarneskinMay 18.2010 — If this is your first time, thats too much code. Here, I reduce it to one line in the function...
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD><TITLE>Tu4-50pm27</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<STYLE type=text/CSS>


</STYLE>
<SCRIPT type="text/javascript">
function shoh(id){ var d=document.getElementById(id);
d.style.display=='none'?d.style.display='block': d.style.display='none'
}
</SCRIPT>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY scroll="auto">
<img src="img/u.gif" name="imgfirst" width="9" height="9" border="0" >
<a href="#first" onClick="shoh('first');" >Customer Support</a>

<div style="display: none;" id="first" >
With its friendly solutions-oriented approach,.... </div>
</BODY></HTML>
[/code]


The image is almost as easy if you only add another argument to the function to id which image to change, you may have several
Copy linkTweet thisAlerts:
@jamesx521authorMay 19.2010 — Ok, this version works, but it doesn't include the other [B]d.gif[/B], which is the down arrow for closing. Is it possible to fit that one within the equation too?
×

Success!

Help @jamesx521 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...