Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Calculation suggestion. Can anyone help me?

Avatar

Level 2
My problem.



Ive created a form that calculates all the total fields without a problem. The issue Im having is there is a separate part to the form which needs to be included and Im not sure how to go about it. Im assuming that JavaScript will be the best option but Ive been trying to teach myself the last few days and I just want to make sure Im heading down the right path.



Here is a screen grab of what I'm trying to do:

http://img471.imageshack.us/img471/8540/form4nl.jpg



What is required?



As the user fills in the form there is a Sunday to Saturday section which is pretty straight forward. In addition to this section the user can fill in a special items section. Currently the user needs to manually copy the total of the special section into the special column.



The special column can only display one figure. So if the user click on the Monday cell for that column and then changes their mind and click Wednesday the script would need to remove the figure in Mondays cell and apply I to Wednesdays cell.



Wish:



Would it be possible to have it so that the form automatically fills the cell with the total once the user clicks on it?



Am I correct it assuming JavaScript can do this is Designer?



Any suggestions would be appreciated.



Regards, John.
3 Replies

Avatar

Level 2
Ok I have the following in the special column under click:



this.rawValue = spetot.rawValue



Now if there is a figure in the Special Items Total (spetot) it will appear in the field if I click on it. What would be the if statement that would tell it to go back to 0 if one of the other Special fields is clicked?



Should the script start with:



var mayDoc = event.target;

this.rawValue = spetot.rawValue



Any suggestions?

Avatar

Level 2
Ok I've gotten a little further and if someone could tell me if this is the correct way to do it I would be very grateful.



On the Monday special field I have the following script running on the click option:



if (this.rawValue == 1)

{

sunspe.rawValue = ""

monspe.rawValue = ""

tuespe.rawValue = ""

wedspe.rawValue = ""

frispe.rawValue = ""

satspe.rawValue = ""

sunspe.rawValue = ""

} else {

sunspe.rawValue = ""

monspe.rawValue = spetot.rawValue

tuespe.rawValue = ""

wedspe.rawValue = ""

frispe.rawValue = ""

satspe.rawValue = ""

sunspe.rawValue = ""

}



On the Tuesday special field I have the following script on the click option:



if (this.rawValue == 1)

{

sunspe.rawValue = ""

monspe.rawValue = ""

tuespe.rawValue = ""

wedspe.rawValue = ""

frispe.rawValue = ""

satspe.rawValue = ""

sunspe.rawValue = ""

} else {

sunspe.rawValue = ""

monspe.rawValue = ""

tuespe.rawValue = spetot.rawValue

wedspe.rawValue = ""

frispe.rawValue = ""

satspe.rawValue = ""

sunspe.rawValue = ""

}



Now this seems to work. If I have a total at the bottom of the form which is just a FormCalc Special Item 1 + Special Item 2.



If I click on the Monday Special field the total appears (after I click away from the field). If I then click on the Tuesday Special Filed the Monday field is cleared and the Tuesday Field now has the figure shown in the total.



Have I done this correctly?

Avatar

Level 2
Is there a way to have the figure update if the spetot figure is changed?



Would I need another if statement?