• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Access elements in a repeat group , setting values and getting a total

cazmont

New Member
I am not having a lot of luck finding the answer on how to get values or update values in a repeat group.
I am wanting to update a price field in a repeat group, then sum that price field into a total for the form.

The price is to come from a cascading dropdown where the price is an element in the record from that cascading dropdown list.

So if I have a record from a cascading dropdown or database join, record looks like this

id description Section Style Fee
001 astylish 1 2 9
002 bstylish 1 3 15
On selection of 001:

How do I take the $9 fee and put into a repeat group element called sectionfee, and total it to a form field called
formtotal.
 
the shows the section description and stores the id on selection. the fee is another element in the record from the ccd.
 
Can anyone further assist me here as I am still looking for a solution,
I am still looking for how access to group elements can be done and suming those elements on a form.​
 
I'm still not sure what your setup is (your previous posts says "the shows the section [..]" which doesn't tell me much.

I'm going to need to see the page, can you give us a URL or fill out your My Sites.

-- hugh
 
Yes sure
http://webtest.cazmont.com.au/index.php/register/registration

On the page you will see age at event, When you select it you will see it populate a drop down in the group called Registration Solo Restricted, the record collected in the dropdown will have a fee for the record that I want to update into the fee field in that group record.
I don't know how to access that fee record in the group with javasript, and I will want to total all the lines in the group on the form into subtotal on the form.
I have written code in many languages and currently studying javascript but am in a hurry to complete this method of working with group records. and updating or using records in a group.
Robert.
 
you may have to login to the form to see the ability to add more records in the group on registration form.
I can provide login if required, but I am sure you can work out that there is the ability to have multiple records in that group.
 
I am confortable with this code working on access to a form record.

var adminfee=Fabrik.getBlock('form_1').formElements.get('registration_solo_duo_trio___AdministrationFee');
var subtotal=Fabrik.getBlock('form_1').formElements.get('registration_solo_duo_trio___SubTotal');
var donation=Fabrik.getBlock('form_1').formElements.get('registration_solo_duo_trio___RegistrationDonation');
var total=Fabrik.getBlock('form_1').formElements.get('registration_solo_duo_trio___RegistrationTotal');
total.update(Number(subtotal.get('value'))+Number(adminfee.get('value'))+Number(donation.get('value')));


But don't know how to access and update group elements.

ie for summing the fee record in my for,, I would also like to automatically populate the line field with an automatically incremented value.
 
you may have to login to the form to see the ability to add more records in the group on registration form.
I can provide login if required, but I am sure you can work out that there is the ability to have multiple records in that group.

Can you provide a login in your My Sites (link to the left of all your posts).

-- hugh
 
I've removed the credentials from your post. Can you use the "My Site Info" link (to the left of any of your posts) and put your site details there? Only Fabrik support staff can see that information, rather than publishing to the world in a public thread.

I'm now logged in, btw, but we still need that info in yoru My Sites so I'm not the only one who can log in. I'll give you the pointers you need as soon as I can.

-- hugh
 
OK, to get all of the repeats, the most straight forward way is just to do a standard selector on the ID, then each() through those, and use the Fabrik object's getValue() method.

Code:
function doTotal() {
  var myTotal = 0;
  var myForm = Fabrik.getBlock('form_1');
  document.getElements('input[id^="registration_solo_duo_trio_10_repeat___RDRFeeValue_"]').each(function (el) {
    myTotal += myForm.formElements.get(el.id).getValue();
  }
  myForm.formElements.get('registration_solo_duo_trio___SubTotal').update(myTotal);
}

You want to add the rest of the code (from your post #8) at the end of that function.

Then you'd call that function from the JavaScript settings for the elements which currently trigger the calc of the individual fee values, using either a 'change' or a 'click' event (probably click for the dropdown).

You'd also need to add a ./components/com_fabrik/js/form_1.js file, which handled adding an event watcher for rows being removed from the repeat group, and call the func form there as well, something like ...

Code:
window.addEvent('fabrik.loaded', function () {
  Fabrik.addEvent('fabrik.form.group.delete', function(form, ev, group) {
      if (group.id == 'group10') {
        doTotal();
      }
  });
});

This is all off the top of my head, so you'll probably need to tweak things a little, but should be close.

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

Thank you.

Members online

Back
Top