<script type="text/javascript"> function fib(m) { document.form.textarea.value += ("argument = "+m+"\n"); var r; if (m<2) { r=1; } else { r=fib(m-1)+fib(m-2); } document.form.textarea.value +=("result for argument: "+m+" = "+r+"\n"); return r; } function exec() { fib(5); } </script> <form name="form"> <input type="button" onClick="exec()" value="click"><br> <textarea name="textarea" cols="32" rows="39"></textarea> </form>