Forums

how to make an onclick button update fields on the form

rockie12 04 Jan, 2009
Hi all

How can I make
<button onclick(someFunctionInTheJavascriptSection) >

update fields on the form, but not submit the form? Like this...

Height <input type="text" name="height" size="5"><br>
Width <input type="text" name="width" size="5"><br>
<button onclick(someFunctionInTheJavascriptSection) >Calculate Area</button>
Area = <input type="text" name="area" size="5" value="">


in the above example when the Calculate Area button is pressed, it will take the values from height and width and do the math and set the value to the Area input box.

I do not want the form to submit to a new screen, just simply call the java script function to do the calculation,

When I try this, the form submits to a blank form.

THanks in advance
Dean-O
GreyHead 04 Jan, 2009
Hi Dean-O,

Try
<input type='button' name='calc' id='calc' value='Calculate Area' onClick='someJavascriptFunction();' />

Bob
This topic is locked and no more replies can be posted.