Passing Data from a field to the function

The .value attribute

function MyFunction1()

var w = parseInt(document.form1.field1.value,10);
var x = parseInt(document.form1.field2.value,10);
var y = parseInt(document.form1.field3.value,10);

var z = w+x+y;
document.form1.field4.value=z

// This is the code added for assignment 4
function MyFunction2()
{
if(document.form1.field4.value=="")
{
alert("The field is blank! We should do something about that!");
/* This line was just for fun.
It puts a random number between 0 and 100 in the field. */

document.form1.field4.value=(Math.floor(Math.random()*100));
}
}


<form name="form1">
Enter W:<input type = text name=field1>
Enter X:<input type = text name=field2>
Enter Y:<input type = text name=field3>
Z = W+X+Y:<input type = text name=field4>
</form>
Enter W:
Enter X:
Enter Y:
Z = W+X+Y: