The form has a dropdown field: Metre_Feet_display
with 2 options - Feet or Metres & commit selected value immediately is checked.
The form also has a number field: veRow1_3
I want to display either “ ft” or “ m” as a suffix to veRow1_3 based on the value of Metre_Feet_display
I have entered this code in the custom format script:
if (event.value) event.value = event.value +(this.getField("Metre_Feet_display").valueAsString);
This works when I enter a number in veRow1_3 and tab out of it. But If there's already a number entered, and I change Feet to Metres in the dropdown, it doesn’t update. I’ve tried variations of my code using .target.value but to no avail so far.
As an aside, I’m also using Metre_Feet_display value to determine a factor for use in a calculation that also uses the value of veRow1_3. This calculation doesn’t update either until I’ve updated/revised veRow1_3 value. I suspect if I can resolve the suffix issue, I can figure out the latter issue.
What am I doing wrong? TIA
You won't be able to do it just using format script,to live update changes you need calculation script.
Can you share file here so we can take a look?
Should field veRow1_3 be equal to Metre_Feet_display?
No - it's a data entry field but I want the suffix to be Metre_Feet_display.
See if this is anything close to what you looking for:
TIP: Since you used Math.log and Math.sqrt there is also Math.PI it returns Pi.
Oh Nesa Thank you. The suffix is perfect. I could never have managed the code you've added. The Temp calc uses the wirefactor (which is driven by the change in feet or metres). While I can see the factor change, it's not getting incorpoarted into the calc. I hope it's something simple.
Where in calculation is problem, can you describe?
Sure. The mathematical calculation is fine. But it uses:
var Fact = this.getField("wirefactor").value;
wirefactor value is determined by the option selected in measure_scale dropdown.
So when it's set to metres, the value is 1, when feet, the value is 0.3048.
The value is setting correctly as I change the dropdown selection but it is not updating the calculated field in Wire GaugeRow1_2
Does this help clarify? I appreciate your help.
Where in calculation is "Fact" used?
Thats not new file.
I really do appreciate your time. This is so strange. It's not working.
When set to metres, with 50a & a total of 10 between -ve & +ve (made up anyway you like), the answer should be 3.33.... It calculates correctly when set to metres, 50a, 0 in -ve & 10 in +ve. Any value in -ve and it doesn't calculate correctly.
With the same settings for feet - the answer should be 8.45. Again, where the +ve is 10 but -ve 0, the answer is correct. Any value in -ve and it doesn't calculate correctly.
And when I change the dropdown, even when only the +ve value entered, it doesn't recalculate for me. I have to delete the contents first. Sorry to be a pain.
Brilliant! Thank you so much!