codice:
function scrivi() {
 var anni;
 var num;
 if (document.nomeform.anni.value=='') {
  anni = 0;
 }
 else {
  anni = document.nomeform.anni.value;
 }
 if (document.nomeform.numero.value='') {
  num = 0;
 }
 else {
  num = document.nomeform.numero.value;
 }
 document.getElementById("miodiv").innerHTML = "Tizio ha " + anni " anni e il suo numero è " + num;
}

....
....


<form name="nomeform">
<input type="text" name="anni" onchange="scrivi();" />


<input type="text" name="numero" onchange="scrivi();" />
</form>
<div id="miodiv">
</div>