Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Closed Thread
setTimeout Problem. Undefined!
Old 11-30-2008, 01:20 PM setTimeout Problem. Undefined!
Skilled Talker

Posts: 64
Trades: 0
HTML Code:
<html>
<head>
<script type="text/javascript">
function count(divid) {
var divh = document.getElementById(divid).offsetHeight;
alert(divh +"px " +divid);


	function doit(divid, divh){
	var p=divh;
	while (p >= 0){
setTimeout("whatis('"+divid+"',"+p+");", 1000);
	var p=p-1;}
	}

doit(divid, divh);

}



function whatis(divid, divh){
document.getElementById('p').innerHTML=divh;
document.getElementById(divid).style.height=divh;};
</script>
</head>
<body>
<div id="top" class="top" style="width:300px; overflow:hidden;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent blandit venenatis purus. 
Integer massa libero, vehicula id, consequat sed, tincidunt nec, purus. Class aptent taciti 
sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse potenti. 
</div>
<br><br>
<input type="button" value="ggg" onClick="count('top');">

<div id="p"></div>
</body>
</html>
This doesn't seem to work but I'm not sure how I could achieve it any other way. The setTimeOut doesn't wait one second before removing the next pixel.

I'm new to setTimeout, any idea where I'm going wrong?

In the unlikely event that you don't know what I'm trying to do, I'm trying to get the pixel height of the div to lower every half second.

Last edited by Petsmacker; 11-30-2008 at 02:01 PM..
Petsmacker is offline
View Public Profile
 
 
Register now for full access!
Old 11-30-2008, 02:12 PM Re: setTimeout Problem. Undefined!
Skilled Talker

Posts: 64
Trades: 0
Any way to delete these threads? A friend of mine has helped me out and got it working.

Last edited by Petsmacker; 11-30-2008 at 02:32 PM..
Petsmacker is offline
View Public Profile
 
Closed Thread     « Reply to setTimeout Problem. Undefined!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28175 seconds with 12 queries