Darkmatter5 Posted February 10, 2009 Share Posted February 10, 2009 Here's the Javascript function togspan(c_img) { if(document[c_img].src.indexOf("images/minus.gif")!= -1) document[c_img].src="images/plus.gif"; else document[c_img].src="images/minus.gif"; var notesID=document.getElementById("notes"); if(notesID.style.display="none") { notesID.style.display="block"; } else { notesID.style.display="none"; } } Here's the CSS #notes { display: none; } Here's the HTML <a href="javascript:togspan('img');"><img name="img" src="images/plus.gif" border="0" width="11" height="11" style="float: left;"></a><span class="medium_text">Notes & instructions: <span id="notes" class="medium_text"><ol> <li>All fields marked with a red asterisks denotes a required field.</li> <li>Game cover scans you supply are not always used in the final database record.<br> If we deem the image of poor quality, etc... we will most likely delete the image<br> and aquire one on our own.</li> </ol></span> The image starts off as "plus.gif" and the span as "display:none;" as expected, and clicking the image changes the image to "minus.gif" and the span does change to "display:block;", but clicking again only toggles the image and doesn't recollapse the span. Why?? Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 11, 2009 Share Posted February 11, 2009 The problem is in the second IF statement where the code is SETTING the value instead of TESTING the value. Need to use a double equal sign. function togspan(c_img) { if(document[c_img].src.indexOf("images/minus.gif")!= -1) { document[c_img].src="images/plus.gif"; document.getElementById('notes').style.display="none"; } else { document[c_img].src="images/minus.gif"; document.getElementById('notes').style.display="block"; } } Quote Link to comment Share on other sites More sharing options...
Darkmatter5 Posted February 11, 2009 Author Share Posted February 11, 2009 Perfect, thanks!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.