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. Link to comment https://forums.phpfreaks.com/topic/177361-solved-set-height-to-auto/ 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 Link to comment https://forums.phpfreaks.com/topic/177361-solved-set-height-to-auto/#findComment-935157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.