Radio button calculation

Issues related to forms.
Post Reply
Thorx_Creed
 
 
Posts: 6
Joined: Thu Jan 19, 2017 12:07 am

Radio button calculation

Post by Thorx_Creed »

Hello WWB,

I have ran in to a stumbling block. I have a calculation sheet with 3 edit boxes that a user can input numerical data into. These are semi permanent numbers that change with the user, but once they are entered they calculate with in the formula. I have assigned a radio button per edit box. What I am trying to accomplish is when the radio button is selected it takes the number value that is in the edit box and plugs it into the calculation. I have looked at the samples that are on the web site, but the value entered in the radio button is a fixed number, in my case the number is unknown until the user enters it into the edit box. Do I just put the edit box ID into the value of the radio button?
User avatar
Pablo
 
Posts: 21699
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Radio button calculation

Post by Pablo »

I'm sorry, there is no standard solution for this. This will require a custom script.
Thorx_Creed
 
 
Posts: 6
Joined: Thu Jan 19, 2017 12:07 am

Re: Radio button calculation

Post by Thorx_Creed »

Ok, that's fair. Second when I do my calculations it seems that I cannot assign a condition calculation to a certain box. I have to do all my condition calculation in one box for the entire sheet. I have tried doing it per object that I would like to use, but the calculations do not work. When I put them all in one condition they all work flawlessly. What am I doing wrong?
User avatar
Pablo
 
Posts: 21699
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Radio button calculation

Post by Pablo »

You will have to make sure that calculations in one object are not undone by calculations from another box.
Thorx_Creed
 
 
Posts: 6
Joined: Thu Jan 19, 2017 12:07 am

Re: Radio button calculation

Post by Thorx_Creed »

So I found a solution to the first problem. Radio buttons placed in a group, if radio button selected to will take the user input "A" and divide it into the constant number "B". Any radio button change or user input change, changes the equation.

Yes, I found the logic error in the conditions.

Now I have calculated the above equation as String(Number([A]) / Number()) which calculates the equation to 2100.8403361. I want to remove everything after the decimal point using .toFixed(0). This is not working, I am sure I am putting it in the wrong place. I also tried Number.toFixed(0) and num.toFixed(0). This is what I have tried so far

String(Number([A]) / Number()).toFixed(0)
String(Number([A]) / Number().toFixed(0))
String(Number([A]) / Number())Number.toFixed(0)
String(Number([A]) / Number()Number.toFixed(0))
And so on.....
User avatar
Pablo
 
Posts: 21699
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Radio button calculation

Post by Pablo »

it looks like you forgot a closing parenthese:

Code: Select all

String(Number([A]) / Number([B])).toFixed(0)
should be:

Code: Select all

String(Number([A]) / Number([B])).toFixed(0))
Note that this is standard JavaScript so not directly related to WWB.
Thorx_Creed
 
 
Posts: 6
Joined: Thu Jan 19, 2017 12:07 am

Re: Radio button calculation

Post by Thorx_Creed »

Thanks Pablo, that did the trick. Everything working correctly.
Post Reply