Jump to content

[SOLVED] Set Height to auto


AE117

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.