matfish Posted April 27, 2007 Share Posted April 27, 2007 Hi, my javascript skills are not as good as my php but ill address the issue. Iv got a simple show/hide div (display:none; display:block; kinda thing). Onload its shown, and the content within is displayed. but then i hide it, but when i click the link to display it again the content within is gone? But this is only happening in IE, FF works no probs. Any ideas why is does this? JS: function show_images(){ document.getElementById('img_list').style.display='block'; } function hide_images(){ document.getElementById("img_list").style.display="none"; } Quote Link to comment Share on other sites More sharing options...
tomfmason Posted April 27, 2007 Share Posted April 27, 2007 I normally like it all in one function. Like this... function showHideDiv(id) { div = document.getElementById(id); div.style.display = (div.style.display == 'none')? 'block' : 'none'; } Try that and I bet you will find it easier to work with. Quote Link to comment Share on other sites More sharing options...
matfish Posted April 27, 2007 Author Share Posted April 27, 2007 Hi, the code you provided is just a neater way of what I did - thanks - but I still get the issue of the contents within the DIV are not displayed when I toggle the show/hide link. I do have 3/4 div's within this 1 div Im toggling - would this cause an issue? Thanks for your replies. Quote Link to comment Share on other sites More sharing options...
nogray Posted April 27, 2007 Share Posted April 27, 2007 can you post some of your html as well? Quote Link to comment Share on other sites More sharing options...
matfish Posted April 27, 2007 Author Share Posted April 27, 2007 The div im trying to show/hide is the id="img_list" <div class="top_right_image_space" id="img_list"> <div id="motioncontainer"> <div id="motiongallery"> <nobr id="trueContainer"> <a href="javascript:void(0);" onclick="javascript:change_image('1');"> <img src="image_assets/thumb_image1.jpg" border="1" alt="1"></a> <a href="javascript:void(0);" onclick="javascript:change_image('2');"> <img src="image_assets/thumb_image2.jpg" border="1" alt="2"></a> </nobr> </div> </div> <div class="hide_more_images"> <a href="javascript:void(0);" onclick="javascript:hide_images();" class="hide_link">[X]</a> </div> </div> But when its shown again the contents within has disappeared. This only happening in IE. Many thanks Quote Link to comment Share on other sites More sharing options...
matfish Posted April 27, 2007 Author Share Posted April 27, 2007 The site is under development and password protected - I can open up for you to view source but didnt want everyone mocking the site. Quote Link to comment Share on other sites More sharing options...
matfish Posted April 30, 2007 Author Share Posted April 30, 2007 Sorry to bump - any ideas anyone? Many thanks Quote Link to comment Share on other sites More sharing options...
ki Posted April 30, 2007 Share Posted April 30, 2007 function Div_Toggle(e) { var dd = document.getElementById(e); if (dd.style.display == "") dd.style.display = "none"; else dd.style.display = ""; } Quote Link to comment Share on other sites More sharing options...
matfish Posted May 1, 2007 Author Share Posted May 1, 2007 Hi, thanks for the replies. I did a bodge job and rather than hiding/showing the div, I resized it to show/hide and this works. Like this: function show_images(){ //document.getElementById('img_list').style.display='block'; document.getElementById('img_list').style.height='130px'; document.getElementById('motioncontainer').style.height='95px'; document.getElementById('motiongallery').style.height='95px'; document.getElementById('hide_more_images').style.display='block'; document.getElementById('img_desc').style.display='block'; } function hide_images(){ //document.getElementById("img_list").style.display='none'; document.getElementById('img_list').style.height='0px'; document.getElementById('motioncontainer').style.height='0px'; document.getElementById('motiongallery').style.height='0px'; document.getElementById('hide_more_images').style.display='none'; document.getElementById('img_desc').style.display='none'; } Iv got another JS issue but ill post when ready in appropriate section. Thanks again. 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.