Copy link to clipboard
Copied
Hi there,
Is it possible to use a variable from a previous form as the default value (only) in another form?
For example, a previous form has the name 'totalhours' and calculates a total value of 6.25.
In my next form I would like to reference that value as the default value in a new text field, but allow the user to enter a new value independent of the previous variable 'totalhours'.
I see other posts where it is possible to set the defaultvalue, but I am unable to work out the javascript to my particular circumstance. In other words, I would like the default value for my new field 'desiredhours' to be generated from 'totalhours' merely as a default value.
If that's not clear enough, let me add that if I enter a new value in 'desiredhours' it will be a new value and not affect the original 'totalhours' it merely uses the value as a display start point.
Copy link to clipboard
Copied
When you say "default value" do you mean initial value that can be overwritten, or do you mean default value that it will return to when the field is reset? Do you want these forms connected so that 6.25 (in this example) is automatically used as the default value, or are you wanting to manually set it in form #2?
Copy link to clipboard
Copied
Yes, I mean the default value that can be overwritten. I do NOT want the forms connected (such as totalhours#1)
I would like the new form to set a unique new field value, but use the calculation from the previous form as a starting point.
Copy link to clipboard
Copied
As an aside - it would be great if I could simply reference a field name in the 'default value' dialog box of options. (With no javascript required)
For example, I can manually enter any number or text as a 'default value' but if I could enter a variable reference such as #totalhours or $totalhours in this box, that would be superb. (I'm assuming that's not a thing?!)
Copy link to clipboard
Copied
No, but you can do it using a simple calculation script:
if (event.value=="") event.value = this.getField("totalhours").value;
Copy link to clipboard
Copied
Fantastic! It displays the right value, but for some reason, it works differently from a 'default value' because the other fields that use this field for calculation still assume a value of nil? (Until I type something in)
Is there a way to access/apply the same 'default value' variable?
Copy link to clipboard
Copied
Check your calculation order.