function that will do calculation

# Thread: function that will do calculation

1. Member
Join Date
Dec 1969
Posts
70

## function that will do calculation

Hi!<BR>I need to find out if it is possible to have a form with different values that as the user enters two particular values, there is another field that will display the difference between the two values entered. Is this possible? If so, is there an example of how this would be done? If multiple calculations are needed - would it be best to set this up as a function? These fields will also need to be a part of the form that will be submitted into a database.<BR>Thanks in advance!<BR>-L

2. Member
Join Date
Dec 1969
Posts
71

## RE: function that will do calculation

Imagine you have three textboxes<BR><BR>After user enters two values and comes to third text box...<BR><BR>You can write a client side function onfocus of third text box and calculate the value for it<BR><BR>&#060;script language="vbscript"&#062;<BR>function find_third_value()<BR>f1.third_value.value = f1.first_value.value + f1.second_value.value<BR>end function<BR>&#060;/script&#062;<BR><BR>do you want this...?

3. Member
Join Date
Dec 1969
Posts
70

## RE: function that will do calculation

How would I call this in the input box?<BR>Thx!

4. Member
Join Date
Dec 1969
Posts
44

## RE: function that will do calculation

well, I think he/she wants to do this WHILE the user types the numbers. call this function in both the key_up event of the two input boxes....<BR><BR>like:<BR>Sub text1_onkeyup<BR> &#039;call his function here<BR>End Sub<BR><BR>Sub text2_onkeyup<BR> &#039;call his function here also<BR>End Sub<BR><BR>

5. Member
Join Date
Dec 1969
Posts
70

## RE: function that will do calculation

Ok, I apologize - I am still learning this stuff.<BR>How would I go about doing this if the user enters 2 times in 2 separate boxes, and the travel times are in a database, and the travel times are unique for each field in the form based on the name of the run (which matches up to the run name in the table). I need to have the plan fields come from what the user enters into the first two text boxes plus the travel time (which depends on the name). Any ideas/examples of how exactly to do this? <BR>Your help is greatly appreciated.<BR>Thx!<BR>-L

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•