<script type="text/javascript"> function foo(obj,id){ document.getElementById(id).innerHTML=obj.value; } </script> <input type="text" onkeyup="foo(this,'res');" /> <div id="res"></div>