Link to home
Start Free TrialLog in
Avatar of m_mlynek
m_mlynekFlag for Denmark

asked on

Javascript counter reset

I have a script that counds back from X number of secounds, when the count reaches 0 a layer is displayed with a button. When the button in the layer is clicked the counter shoud startover and the layer should be hitten again, and only be displayed again when the counter again reaches 0. Can anybody help me, it should be easy, but everything i have tried haven't been working...

<input type="text" id="counter_advarsel">
<script>
function reset_counter() {
//here i need to reset the counter and hide the popup layer!!!???    
   
   
}
var countdownfrom=5;
var currentsecond=document.getElementById('counter_advarsel').value=countdownfrom+1;

function count_advarsel_function() {
if(currentsecond != 1) {
currentsecond -= 1;
document.getElementById('counter_advarsel').value=currentsecond;
} else {
document.getElementById('counter_div_advarsel').style.visibility = "visible";
document.getElementById('counter_div_advarsel').style.filter='progid:DXImageTransform.Microsoft.Shadow(color=#B5BDCB, direction=135, strength=6)';
document.getElementById('counter_div_advarsel').style.left = (winW/2)-(300/2);
document.getElementById('counter_div_advarsel').style.top = (winH/2)-(300/2);
}
setTimeout("count_advarsel_function()",1000);
}

document.onload = count_advarsel_function();
</script>
<?php
echo "<div style=\"z-index: 8000; position: absolute; visibility:hidden; top: -1000; left: -1000;\" id=\"counter_div_advarsel\">";
            echo "<table style=\"background-color: #ffffff; border: 1px solid #B5BDCB; width: 300px; height: 100px;\">";
            echo "<tr><td style=\"padding-left: 8px; padding-top: 4px; font-weight: bold; height: 24px;\" class=\"BorderBottom\">Automatisk log af advarsel</td></tr>";
            echo "<tr><td style=\"height: 60px; padding-left: 8px; padding-right: 8px; padding-bottom: 8px;\" class=\"BorderBottom\">";
            echo "<li>Du har nu været inaktiv i 18 minutter og vil, af sikkerhedsmæssige hensyn, defor automatisk blive logget af om 2 minutter.</li><br /><li>Gem alt igangværende arbejde eller genoptag brugen af systemet.</li>";
            echo "</td></tr>";
            echo "<tr><td style=\"text-align: center; height: 40px; vertical-align: middle;\">";
            echo "<input class=\"Knap\" type=\"button\" name=\"ok\" value=\"Ok\" style=\"width: 90px;\" onclick=\"javascript: reset_counter();\" ".$_SESSION["knap_opsaetning"]." />";                              
            echo "</td></tr>";
            echo "</table>";
echo "</div>";
?>
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Fixede den for FF nu jeg var igang ;)
Avatar of m_mlynek

ASKER

Mange tak for den hurtige hjælp... Virker perfekt, min dag er reddet... ;o) har givet dig point.