AE117 Posted October 12, 2009 Share Posted October 12, 2009 Is there a way to set the height to auto instead of a fixed value? I have this so far <script language="javascript"> function changeheight(){ e=document.getElementById("commentdiv"); if (e.style.height = 150) {e.style.height = auto; } else {e.style.height = 30 + 'px';}} </script> but it only works if i set it like so <script language="javascript"> function changeheight(){ e=document.getElementById("commentdiv"); if (e.style.height = 150) {e.style.height = 350 + 'px'; } else {e.style.height = 30 + 'px';}} </script> 350 being the set value is there a way to make this auto thanks. Quote Link to comment Share on other sites More sharing options...
AE117 Posted October 12, 2009 Author Share Posted October 12, 2009 Apperantly I am a retard and did not notice that i didnt use "" around auto. So there you have it the code to change a div height to auto is as follows <script language="javascript"> function changeheight(){ e=document.getElementById("commentdiv"); if (e.style.height = 150) {e.style.height = "auto"; }} </script> Please remeber to change the div id to your id, I hope this helps someone 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.