DavidB
02-04-2007, 05:26 AM
Hi, folks.
Is there a way to dynamically write text to an existing webpage with Javascript?
I am writing a page with a solver (in Javascript) that calculates the roots of a quadratic equation.
The user inputs the polynomial coefficients via fields in a form.
I was hoping to output the results neatly below the form using Javascript’s document.write method. This way, if no imaginary components are present, an imaginary field won’t be output at all (to possibly cause confusion among high-school students who have never dealt with imaginary numbers). However, it seems that document.write cannot be used like I want from within an EventHandler-–it would overwrite the existing page. So I cannot simply tell users to click the “Find Roots” button and have the solutions output lower down on the page.
Any suggestions for accomplishing what I want?
Thanks.
David
Is there a way to dynamically write text to an existing webpage with Javascript?
I am writing a page with a solver (in Javascript) that calculates the roots of a quadratic equation.
The user inputs the polynomial coefficients via fields in a form.
I was hoping to output the results neatly below the form using Javascript’s document.write method. This way, if no imaginary components are present, an imaginary field won’t be output at all (to possibly cause confusion among high-school students who have never dealt with imaginary numbers). However, it seems that document.write cannot be used like I want from within an EventHandler-–it would overwrite the existing page. So I cannot simply tell users to click the “Find Roots” button and have the solutions output lower down on the page.
Any suggestions for accomplishing what I want?
Thanks.
David