[clug-progsig] Javascript how to write to a <textarea>
Dave Lee
dave at cherryville.org
Wed Feb 9 08:13:38 PST 2005
Doug Boyd wrote:
> Upon completion of the function, the windows resets.
> I put the alert in to see what is happening.
first, change the submit button into a regular button, and second, move the onsubmit event handler
to the onclick event handler of the button. for example:
<form name="myoutput">
Enter total number of disks
<input type="text" name="totaldisks" size="10">
<input type="button" value="Solve"
onclick="solve(document.myoutput.totaldisks.value,1,3,2)"/>
<br /><br /><br />
<textarea name="box" id="box" cols="30" rows="10">Solution presented here.
</textarea>
</form>
by using a submit button the browser was submitting the form back to the page itself, which results
in a reset of the page as though you had hit the refresh button.
one thing trick/tip that I'll mention that has nothing to do with your question is the call to solve
uses document.myoutput.totaldisk.value, but you could also use this.form.totaldisk.value, where
"this" refers to the button being clicked, and "this.form" refers to the form of the button being
clicked. I like to use this.form because it's a more encapsulated.
Dave
More information about the clug-progsig
mailing list