How to apply form using JS before redirecting page

ricslabb03

Member
This is the situation:

We are building a quote system. Within a quote you have quote items (as a repeated group) and then within each quote item there are different area items for the different areas (such as lobby, corridor etc...).

One option to the issue of a repeated group within a repeated group is to have a button in the quote item group that applies the quote and redirects to the area items list where you can add area items to that quote item.

My question is whether it is possible to call the apply button's code in the form of a custom button before redirecting the page in a javascript element plugin?

Should you require any additional information don't hesitate to ask. I'm still a noob at asking questions on forums so don't know all the protocols. :D
 
I have been playing around with this solution, but it freezes the browser. I think it's because it is trying to update too many fields at once?

I placed this code in a button element.

JavaScript:
var quote_form = Fabrik.getBlock('form_70').formElements;

quote_form.each(function(value, key) {
    var elementname = quote_form.get(key);
    var elementvalue = elementname.getValue();
    elementname.update(elementvalue);
});

After this code is completed I will redirect the page.
Is this a possible solution? Is there a way to improve it?

Thanks. :D
 
I realize that that won't work. There is too many things to save, plus update() doesn't save the values to the database. (Sorry, I am not experienced in js as of yet!) I would need to use AJAX if I was to pursue this solution. Is there not just a simple function that I can call to apply the apply button's code?
 
We have changed the plan slightly: I still need the apply code to run when I press a button, but I am going to open a modal window instead of redirecting.

Is there not just a simple function that I can call to apply the apply button's code before opening the modal window?

I need to apply the quote form, because after I am done with the area items modal window it refreshes the quote form to show the updated area items, so any entries into the quotes table that were not saved will be lost.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top