Hi, I have written a php/javascript code to check a database for a variable, which is 15 seconds to display something, or 30 seconds. Then it sends the variable to javascript to run the countdown. It works in firefox, but when I try it in IE7, the countdown starts at 10 seconds no matter what.

<script language="JavaScript" type="text/javascript">

<?php

$sqlh = "SELECT * FROM tb_ads WHERE id='$adse'";
$resulth = mysql_query($sqlh);        
$myrowh = mysql_fetch_array($resulth);
$plan = $myrowh["visittime"];

if($plan=="15"){
$time = 16;
}else{
$time = 31;
}

echo "var x = ".$time;
?>

var y = 1

function startClock(){

if(x!=='Done'){

x = x-y

document.frm.clock.value = x

setTimeout("startClock()", 1000)

}

if(x==0){

x='Done';

document.frm.clock.value = x;

success.location.href="success.php?ad="+document.frm.id.value+"&
verify="+document.frm.verify.value;

}}

</script>

Ok, still no replies. Well, then does anyone know of another way I could do it?

Ok so I tested it in IE 7 again, and it still starts the countdown at 9(or 10 - 1). Here is the source code that the browser gets. Why won't it work?

<script language="JavaScript" type="text/javascript">

var x = 31
var y = 1
function startClock(){
if(x!=='Done'){
x = x-y

document.frm.clock.value = x

setTimeout("startClock()", 1000)

}

if(x==0){

x='Done'

document.frm.clock.value = x

success.location.href="success.php?ad="+document.frm.id.value+"&verify="+document.frm.verify.value

}}

</script>

</head>

			
			<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" onLoad="startClock()">

You need to post this question in javascript forum. I am sure you ll get better help there.

Member Avatar for fatihpiristine

gotta be kidding about this one
180 seconds, now on up to you.

<META HTTP-EQUIV="Refresh" CONTENT="180">

works everywhere. u no need java everytime

I took the code you pasted above and tested it locally with IE7 and it started the countdown at 30...

check to make sure you don't have an initial value set in your form 'document.frm.clock' element... or aren't setting it anywhere else in the document

as an aside, I would recommend using semicolons at the end of your javascript lines...it makes for much cleaner code.

what is this script for if I may ask.
because I'm searching the same type of script I think.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.