semplice esempio:

codice:
<html>
<head>
<title>Esempio</title>

<script language="JavaScript">

function somma(){
 var n=null;
 var somma=0;
 while(isNaN(n) || n==null) n=parseInt(window.prompt("Inserire un numero:"));
 for(i=n;i>0;i--) if(i%2==0) somma+=i;
 alert("La somma dei numeri pari tra "+n+" e 0 è "+somma+ ".");
}

</script>

<head>
<body onload="somma();">
</body>
</html>
ciao