I have 4 text boxes in a colmn and a total box at the end. The total box will be the sum of the values in textboxes 1-4. How do I get the total box to sum when alues are added or changed in any of the four boxes?
Printable View
I have 4 text boxes in a colmn and a total box at the end. The total box will be the sum of the values in textboxes 1-4. How do I get the total box to sum when alues are added or changed in any of the four boxes?
Use javascript and write a function to AddUP the values of four text box. Use the OnChange event of each text box to update the calculation by calling the AddUP function.Quote:
Originally posted by realgoldn
I have 4 text boxes in a colmn and a total box at the end. The total box will be the sum of the values in textboxes 1-4. How do I get the total box to sum when alues are added or changed in any of the four boxes?
Is there a way to have a group name for a group of text boxes. So I can say on change event of the group then call addup() or must I reference each textbox separatly cuase I have over 20 of them.
No you cant group them, it wouldnt be much anyway just an extra line for each text box.Quote:
Originally posted by realgoldn
Is there a way to have a group name for a group of text boxes. So I can say on change event of the group then call addup() or must I reference each textbox separatly cuase I have over 20 of them.
For some reason it is treating the value as a string not a number becuase the two values I want to add are 200 + 600 which is 800 but it is displau 200600. Help! This is the function!
sub AddUPEQP()
SET Add = document.Addproj
EQPTotal=add.txteqp1.value
EQPTotal=EQPTotal+add.txteqp2.value
add.txtEQP14.value=EQPTotal
end sub
Use Val()........Quote:
Originally posted by realgoldn
For some reason it is treating the value as a string not a number becuase the two values I want to add are 200 + 600 which is 800 but it is displau 200600. Help! This is the function!
sub AddUPEQP()
SET Add = document.Addproj
EQPTotal=add.txteqp1.value
EQPTotal=EQPTotal+add.txteqp2.value
add.txtEQP14.value=EQPTotal
end sub
VB Code:
sub AddUPEQP() SET Add = document.Addproj EQPTotal=val(add.txteqp1.value) EQPTotal=EQPTotal+val(add.txteqp2.value) add.txtEQP14.value=EQPTotal end sub
Is it possible to call two different functions on the onchange() like this
onchange(addup(),totalup())??? Becuase I want to add the totals down and across so I need to different functions.
Never tried it, it wouldnt be advised to do so. Have another function which call those to function, and call that function instead.Quote:
Originally posted by realgoldn
Is it possible to call two different functions on the onchange() like this
onchange(addup(),totalup())??? Becuase I want to add the totals down and across so I need to different functions.
eg.
function myUpdate()
addup();
totalup()
end function
now simply call myUpdate.
Hope this helps.
Danial
Thanks!
You are welcome.Quote:
Originally posted by realgoldn
Thanks!