Jump to content

Recommended Posts

Posted

gostaria de saber, com um codigo em javascript, como modificar o valor do contador decrescente pra 0, dado que esta variavel assume valores random sempre que se abre ou faça reload na página, eis o codigo:

<script language="Javascript">
x"numerorandomgerado"=60;
function countdown() 
{
if ((0 <= 100) || (0 > 0))
{
  x"numerorandomgerado"--;
  if(x"numerorandomgerado" == 0)
  {
   document.getElementById("dl").innerHTML = '<input type="submit" style="font-size:24px; color:#349EEE" value="XXXXXXXXXXX" onClick="window.location=\'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\'">';
  }
  if(x"numerorandomgerado" > 0)
  {
   document.getElementById("dl").innerHTML = '<input type=submit style="font-size:24px; color:#349EEE" value=\"Please wait for '+x"numerorandomgerado"+' seconds..\">';
   setTimeout('countdown()',1000);
  }
}
}
countdown();
</script>
Posted

vê este código

<form name="count">
<font size="6" color="#0000FF"><b>FALTAM</b></font><input type="text" size="69" name="count2">
</form>

<script>

//mensagens,
var before="Ano 2007!"
var current="Chegamos ao ano 2007!Bom ano 2007!"
var montharray=new Array("Jan","Fev","Mar","Abr","Miy","Jun","Jul","Ago","Set","Out","Nov","Dez")

function countdown(yr,m,d){
theyear=yr;themonth=m;theday=d
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[m-1]+" "+d+", "+yr
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
if(dday==0&&dhour==0&&dmin==0&&dsec==1){
document.forms.count.count2.value=current
return
}
else
document.forms.count.count2.value= dday+ " dias, "+dhour+" horas, "+dmin+" minutos, e "+dsec+" segundos para o "+before
setTimeout("countdown(theyear,themonth,theday)",1000)
}
//inseres a data que queres
countdown(2007,1,1)
</script>
</body>

Our lives begin to end the day we become silent about things that matter - Martin Luther King

  • 7 months later...
Posted

Boa tarde,

Ajudem-me pff, coloquei o código citado no frontpage mas apenas me aparece o form com a palavra Faltam e as instruições dentro do form NaN dias, NaN horas, NaN minutos, e NaN segundos para o Ano 2007, em vez do tempo !!!

Obrigado pela ajuda,

Diogo

  • 5 weeks later...
Posted

Boas,

Preciso de ajuda novamente, neste script voltou-me a aparecer em vez dos dias horas etc... a expressão NaN, NaN, como posso corrigir este problema ou qual a causa.Obrigado

Diogo V.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.