CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Coverting JavaScript Function to PHP

Print topic Send  topic

Author Message
Zulu


Posts: 33
Posted: 08/26/2004, 2:27 AM

I have the following js code to show a countdown clock. I need to convert it to php function. Can anyone pls help me?

I used 10 images of digital digits (0-9). The counter says 30 sec initially. With a click of start button the counter counts down to zero and shows a message time's up!


------------------------------------------------------
<script language="JavaScript" src="./Images/pfg.js"></script>
<script language="JavaScript">
<!--
c1 = new Image(); c1.src = "./Images/c1.gif";
c2 = new Image(); c2.src = "./Images/c2.gif";
c3 = new Image(); c3.src = "./Images/c3.gif";
c4 = new Image(); c4.src = "./Images/c4.gif";
c5 = new Image(); c5.src = "./Images/c5.gif";
c6 = new Image(); c6.src = "./Images/c6.gif";
c7 = new Image(); c7.src = "./Images/c7.gif";
c8 = new Image(); c8.src = "./Images/c8.gif";
c9 = new Image(); c9.src = "./Images/c9.gif";
c0 = new Image(); c0.src = "./Images/c0.gif";

var cdrr=0;
var cdlds=0;
var cdss=30;
var cdrr=1;

extract(cdss);

function startCtdn() {
if (cdrr==1){
cdrr=0;
extract(cdss);
setTimeout('ctdnTick()',1000);
}
}

function ctdnTick() {
cdss--;
extract(cdss);

if (cdss==0) {
alert("Time's up!");
cdss=30;
extract(cdss);
cdrr=1;
}
else setTimeout('ctdnTick()',1000);
}

function extract(s) {
if (s <= 9) {
document.g.src = c0.src;
document.images.h.src = eval("c"+s+".src");
}
else {
document.images.g.src = eval("c"+Math.floor(s/10)+".src");
document.images.h.src = eval("c"+(s%10)+".src");
}
}
// -->
</script>

-------------------------------------------------------------------
View profile  Send private message
Karsten
Posted: 08/29/2004, 3:25 PM

Hi Zulu,

You cannot have "running" (animated) things in PHP because
PHP is a Serverside language , what you want to do is possible only with
a clientside language like Javascript is. ok some may say its possible with PHP to but in your case you would have to reload the page every second, this sucks.

why you want not use javascript? almost every browser supports javascript.Forget the 2% of users that have disabled javascript in their browser, because their brain is disabled too....you dont need this 2% of people to have success.

Karsten from Germany (21 years programming expirience)


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.