DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   Works in Firefox, not in IE7 (http://www.daniweb.com/forums/thread105526.html)

priddysharp Jan 20th, 2008 6:42 pm
Works in Firefox, not in IE7
 
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>

priddysharp Jan 21st, 2008 9:50 pm
Re: Works in Firefox, not in IE7
 
Ok, still no replies. Well, then does anyone know of another way I could do it?

priddysharp Jan 21st, 2008 10:24 pm
Re: Works in Firefox, not in IE7
 
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()">
                       

nav33n Jan 21st, 2008 11:06 pm
Re: Works in Firefox, not in IE7
 
You need to post this question in javascript forum. I am sure you ll get better help there.

fatihpiristine Jan 21st, 2008 11:09 pm
Re: Works in Firefox, not in IE7
 
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

johnsquibb Jan 22nd, 2008 12:23 am
Re: Works in Firefox, not in IE7
 
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.

shedokan Jul 11th, 2008 10:26 am
Re: Works in Firefox, not in IE7
 
what is this script for if I may ask.
because I'm searching the same type of script I think.


All times are GMT -4. The time now is 12:56 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC