Could someone please convert the excel formula below into Formscript or Javascript language for me? Sorry, but I've run out of patience.
=((([Cellname]-TRUNC([Cellname]))/60)*100)+TRUNC([Cellname])
Thanks
Scripting HelpI made 4 fields, 2 visible and 2 invisible
Field 1: User enters Data
Field 2: invisible; calculated: Dezimalfield1 * 1; with no aftercommas (right pannel)
Field 3: (this is the [Cellname]-TRUNC([Cellname]): invisible; calculated: Dezimalfield1 - Dezimalfield2
Field 3: validate (javascript)
if (this.rawValue %26lt; 0)
{this.rawValue = this.rawValue + 1}
else {true;}
Field 4 (Solution): calculated: Dezimalfield3 *100 / 60 + Dezimalfield1 - Dezimalfield3
Hope you are alright with this one too, though it's quite complicated
Message was edited by: ocen12%26#13;
%26#13;
Delte the text of the Decimalfield4 calculate and use instead on validate:%26#13;
%26#13;
%26#13;
if (this.rawValue == Dezimalfield3.rawValue *100 / 60 + Dezimalfield1.rawValue - Dezimalfield3.rawValue)%26#13;
{true;}%26#13;
else%26#13;
{this.rawValue = Dezimalfield3.rawValue *100 / 60 + Dezimalfield1.rawValue - Dezimalfield3.rawValue;}%26#13;
%26#13;
Reason: it took the values of Decimalfield3 before validation. The values I tried worked...%26#13;
(Learned another thing. Calculated fields populate with not validated values.)
Hi,
You could also try the following.
Set up a decimal field (different from a numeric field) for the user to input the number. Call this ''input''
Then set up a second field to do the calculation and spit out the answer; call this ''output''.
In the script I have used variables (instead of invisible fields). These hold interim results for the duration of the script.
This is FormCalc:
var inputNr = input聽聽 // sets the variable inputNr as the full number the user inputted
var inputTrunc = Floor(inputNr)聽聽 // truncates the number to an integer without rounding
$ = ((inputNr - inputTrunc) / 60)*100 + inputTrunc聽聽聽 // does the calculation you want
Hope that helps,
Niall
Thanks very much for that. I went with Niall's solution.
Here's another couple though:
=TRUNC([Cellname]/60)+([Cellname]-TRUNC([Cellname]/60))*60)/100)
=([Cellname]-TRUNC[Cellname])*100+TRUNC[Cellname]*60
Don't worry - I've done it!
No comments:
Post a Comment