Một ví dụ nho nhỏ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Java script</title><style>input[type=text]{ width:50px; text-align:center; border:thin solid gray; padding: 2px 5px 2px 5px; border-radius: 3px 3px 3px 3px;}#result{ width:60px; background:#33CC66; color: #FFFFFF; font-weight:bold;}</style><script> function show() { var f = document.getElementById("f"); var s = document.getElementById("s"); var r = document.getElementById("result"); r.value = new Number(f.value) + new Number(s.value); }</script></head><body><input type="text" id="f" onkeyup="show();"/>+<input type="text" id="s" onkeyup="show();"/><input type="text" id="result" readonly="true" /></body></html>