Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calulated fields in a form

Status
Not open for further replies.

tech88

Technical User
Apr 11, 2002
3
US
I am trying to create calclated fields in a (Front Page) form. It should calculate square feet based on Length, Height and Width fields. Length X Height X Width = Square Feet. Then it will calculate how many gallons of paint will be required base on gallons per square foot (constant value).

Is there a way to do a calculation in the form?

I can put together a javascript calculator that gives the results I need but I do not know how to pass this resulting value to the form/field in order to submit the information to a file.
 
Take the final of your calculated variable from the script ie: sqFt=varH * varW * varD

Then create a hidden form field

<input type=&quot;hidden&quot; name=&quot;square_feet&quot;>

Then in the javascript put:

document.form.square_feet.value=sqFt

Pu that in a function called doSqFt or something, then on the submit button:

<input type=&quot;submit&quot; Value=&quot;Submit&quot; onClick=&quot;doSqFt();&quot;>

This will take the value from your script set it as the alternate variable and write the value to the hidden form field. DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top