Expand my Community achievements bar.

SOLVED

Convert Text from Text Field

Avatar

Level 2

For compatability purposes with other forms, I have a text field that numeric data is entered into.  I would however like to perform a calculation off of this field, so would therefore like to convert the number entered into this field into a numeric value rather than a text value.  Can anyone explain to me how this is done?

Thank you in advance!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Depending on the type of number you want you would use parseInt or parseFloat in Javascript. So when addressing your field in the calculation (assuming it is called TextField1)

var myResult = parseFloat(TextField1.rawValue) + 123.45

Make sense?

Paul

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

Depending on the type of number you want you would use parseInt or parseFloat in Javascript. So when addressing your field in the calculation (assuming it is called TextField1)

var myResult = parseFloat(TextField1.rawValue) + 123.45

Make sense?

Paul

Avatar

Level 2

Thank you Paul, that worked perfectly!!!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----