I have a field called 'Length' and I want to have two boxes to be filled in with two values, one for feet and then another for inches. Is there an OOB way to enable this?
Thank you!
I have a field called 'Length' and I want to have two boxes to be filled in with two values, one for feet and then another for inches. Is there an OOB way to enable this?
Thank you!
Hi partner,
Thanks for your details.
You could add another text field to show the complete length with both inch and feet by JS splicing.
For example, I create a new text field named "wholeLength", just add the following code the function "getFeet" in my last answer.
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:9ffc57fa-9bbf-4ecd-b1f6-aa63531fe9cc:type=javascript&text=%20%20%20%20var%20inches2%3DparseInt%28inches%29%2512%3B%0D%0A%20%20%20%20var%20feet2%3DparseInt%28inches%29%2F12%3B%0D%0A%20%20%20%20var%20length%3Dfeet2%2B%22%20feet%20%22%2Binches2%2B%22%20inches%20%22%3B%0D%0A%20%20%20%20formContext.getAttribute%28%22new_completelength%22%29.setValue%28String%28length%29%29%3B]
And add the following code in "getInches" function.
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:9f2538c5-d91f-4926-a49c-4a71ea399f73:type=javascript&text=formContext.getAttribute%28%22new_completelength%22%29.setValue%28inches%2B%22%20inches%22%29%3B]
Regards,
Leo
Hi there, thank you for that explanation! that answer definitely makes sense but I was thinking more of a field for total length and then the user is allowed to enter a value for feet AND inches. So that if the length is 5 feet and 10 inches, there are two fields for which to enter data but the true value for that field would be the summation of the two fields behing the scenes. So the length would be 70 inches stored in the system which then could be converted as 5 ft 10 inches displayed to the user.
Thank you!
Hi partner,
There is no OOB way to do this, so I suggest that you could put two fields on the form named Feet and Inches, and when you enter value in one of them, the another value will be calculated and filled in the field automatically.
To do this, we need use JS code. I wrote two JS functions, and please add "getInches" on Feet field onchange event and add "getFeet" on Inches field onchange event.
function getInches(executionContext){ var formContext=executionContext.getFormContext(); var feet=formContext.getAttribute("new_feet").getValue(); var inches=parseFloat(feet)*12; formContext.getAttribute("new_inches").setValue(String(inches)); } function getFeet(executionContext){ var formContext=executionContext.getFormContext(); var inches=formContext.getAttribute("new_inches").getValue(); var feet=parseFloat(inches)/12; formContext.getAttribute("new_feet").setValue(String(feet)); }
Save and publish.
Then we go back to the form, when we fill value in Feet field, there will be value filled in Inches automatically, And vice versa.
Fill in Feet:
Fill in Inches:
Hope it helps.
Best Regards,
Leo
André Arnaud de Cal...
294,467
Super User 2025 Season 1
Martin Dráb
233,066
Most Valuable Professional
nmaenpaa
101,158
Moderator