m_mlynek
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.get ElementByI d('counter _advarsel' ).value=co untdownfro m+1;
function count_advarsel_function() {
if(currentsecond != 1) {
currentsecond -= 1;
document.getElementById('c ounter_adv arsel').va lue=curren tsecond;
} else {
document.getElementById('c ounter_div _advarsel' ).style.vi sibility = "visible";
document.getElementById('c ounter_div _advarsel' ).style.fi lter='prog id:DXImage Transform. Microsoft. Shadow(col or=#B5BDCB , direction=135, strength=6)';
document.getElementById('c ounter_div _advarsel' ).style.le ft = (winW/2)-(300/2);
document.getElementById('c ounter_div _advarsel' ).style.to p = (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\">Aut omatisk 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_opsaetni ng"]." />";
echo "</td></tr>";
echo "</table>";
echo "</div>";
?>
<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.get
function count_advarsel_function() {
if(currentsecond != 1) {
currentsecond -= 1;
document.getElementById('c
} else {
document.getElementById('c
document.getElementById('c
document.getElementById('c
document.getElementById('c
}
setTimeout("count_advarsel
}
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\">Aut
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_opsaetni
echo "</td></tr>";
echo "</table>";
echo "</div>";
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Fixede den for FF nu jeg var igang ;)
ASKER
Mange tak for den hurtige hjælp... Virker perfekt, min dag er reddet... ;o) har givet dig point.