Solved

PHP->JS (Automatically scroll down)

Posted on 2004-08-22
9
662 Views
Last Modified: 2012-05-05
Hi,
I think you might need a little PHP knowledge here...but either way its quite easy to understand.

This is what I have in my php script

for($i=100;$i>=0;$i--)
{
if($i==0 )
{echo "<h1>BOOM!</h1>";}
else{echo "counting down".$i."<br>";}
echo str_repeat(" ", 256);   flush();   ob_flush();
sleep(1);
}

Basically what it does is, it prints out "counting down <x>" where x is a number like this:
 
counting down 99
counting down 98
counting down 97
etc

till it reaches 0 then it displays "Boom!"
I have also used the "sleep" function so it does not go too fast but shows the "counting down message" every second.

My problem is when it displays the message it does not scroll down...so the user only sees the top half of the page while the "countdown" is still loading below.
Is there any way for this to follow the ouput at the bottom of the page?

I dont know JavaScript too well but I see there are lots of JS gurus here...I'm pretty sure this wont be too tough for ya, sorry I cannot offer more points but thats all that available in my account (I will give an A to the person who solves this though), the points for the people I have helped I cannot seem to touch :-( otherwise i would have offered more to you guys..
but maybe i can make it up to you in future by helping you in some php problem :-)

Thanks,
Mag
0
Comment
Question by:mag1c1an
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 100 total points
ID: 11865914
Thanks for the php offer ;-)

Check this:
echo str_repeat(" ", 256)."<script>window.scrollTo(0,9000)</script";   flush();   ob_flush();

0
 
LVL 2

Author Comment

by:mag1c1an
ID: 11866246
Hey,
I was right....there are JS gurus here!

Works like a charm! Thanks.

As far as I am concerned the points are yours and this is closed, but before I award you the points I have a question about some odd behevior (you get the points if you answer this or not, i just dont know if after I award you the points this will be "open" or "locked")

In Opera I get to see the *second last* line and not the last line...the last line is covered up with the loading bar, any way to take that out so I see the last line?

Cheers,
-Mag
0
 
LVL 2

Author Comment

by:mag1c1an
ID: 11866251
P.S your ending <script> tag was open... :-)
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 63

Expert Comment

by:Zvonko
ID: 11866287
Uhps, sorry :)

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11866299
Is the last line missing also with the correct script end tag?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11866328
How about this:

echo "<div id='msg' style='color:red;'></div><br><br><br>";
for($i=100;$i>=0;$i--){
  if($i==0 ) {
     $msgText = "<h1>BOOM!</h1>";
  }else{
     $msgText = "counting down".$i."<br>";
  }
  echo "<script>document.getElementById('msg')='".$msgText."'</script>";
  echo str_repeat(" ", 256);  
  flush();  
  ob_flush();
  sleep(1);
}



0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11866342
I was not sure if this var is evaluated:
   echo "<script>document.getElementById('msg')='$msgText'</script>";

0
 
LVL 2

Author Comment

by:mag1c1an
ID: 11873098
Hi,
Nah, forget it, it seems that that "feature" is built into Opera. It works great on IE and NN so am happy.

Thanks.
Mag
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11874875
Thanks for points.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question