"Copying" values in a multipage form from one field to another

susannanam

Member
hi all,

i have a little issue with a complex form. it is a multiple page form and values from page 4 shall be copied over to page 6.

here is some more details:
a databasejoin field has a javascript on change:
JavaScript:
if (this.getRepeatNum() == '0') {
   this.form.formElements.mac9k_nsfpis_school_trimform_utilization___unit_weight_0.update(this.getValue());
}

this one works perfectly fine and as soon as a change is done in this field, it reflects on page 6 in the respective database join field.

Issue 1:
the same principle does not work if i have a cascading dropdown field. the field remains empty and only when i select again the "watch value field" on page 6, then it correctly populates the cascading dropdownfield.

Issue 2:
since both pages are repeating groups, the above routine anyway only works if i have 1 line.. .as soon as i add another line, it does not reflect on page 6.


Does anyone have an idea how i can fix this and make it work? thanks
susanne
 
Issue 1 - this is probably because you aren't triggering a change event for the join when you update it in your script. So the CDD won't reload itself, and won't have the options associated with the join selection. Then when you manually trigger an update of the CDD by making a selection on the join, it loads the right options.

You can trigger the change event like this ...

Code:
if(this.getRepeatNum()=='0') {
   this.form.formElements.mac9k_nsfpis_school_trimform_utilization___unit_weight_0.update(this.getValue());
   this.element.fireEvent('change', new Event.Mock(this.element, 'change'));
}

... which should cause the CDD to then update itself with the new options. However, it's possible your update of the CDD may not work, because Javascript is asyncronous. So the update of the CDD will fire off an AJAX call, and update the options when that call returns. And by the time that has happened, your code will probably have already tried to set the value of the CDD.

So you may have to write some more complex JS, which watches for Fabrik events, like fabrik.cdd.update, and then figure out if the CDD being changed is one you are wanting to copy the value of.

Issue 2 - this is something we discussed when I did this work for you. As I said then, it's not going to be easy. And like issue 1, is going to require some more complex JS using Fabrik events, which watch for groups being added or deleted on the first group, and creating / deleting on the second group, and tracking the repeat counts when changing elements, to match the change with the copy.

This isn't something I can do as part of a subscription, it would have to be custom work.

-- hugh
 
Did you send me a PM, or email, or Skype?

I thought I saw your in a notification on my phone the other day, but can't remember what it was, and can't find anything from you.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top