<HTML> <HEAD> <TITLE>......</TITLE> <HEAD> <SCRIPT> function alloc (form) { document.form7.out1.value = 678.4; document.form7.out2.value = 9*9.1; document.form7.out3.value = "multimedia programming"; } </SCRIPT> <BODY> xxxx<BR> xxxx<BR> xxxx<BR> <FORM NAME="form7"> <INPUT TYPE="button" VALUE="display getal" ONCLICK="alloc (this.form)"> <INPUT TYPE="text" NAME="out1" VALUE="aaa" SIZE="12"> <INPUT TYPE="text" NAME="out2" VALUE="bbb" SIZE="8"> <INPUT TYPE="text" NAME="out3" VALUE="ccc" SIZE="16"> </FORM> xxxx<BR> xxxx<BR> xxxx<BR> </BODY> </HTML>
You see the default output in the fields are 'aaa', 'bbb' and 'ccc'. After clicking: '678.4', '81.8999999' and 'multimedia programming'. Did you understand?
The object 'document' has an object 'form7' and in that form there are fields: 'out1', 'out2' en 'out3'. The field only can take over the value if you has programmed '.value', as seen in the statement document.form7.out2.value = 678.4.
The use of 'this.form' in a function can be studied in JavaScript handbooks.
Enschede, 8 jan 2001; updated: jan 28, 2003.