How to conditionally disable the submit button in a Form

rdiana

Member
Hi friends,
in a form I've a calc field which evaluates the number of free places (i.e. in a theatre). I would like to automatically disable the submit button if the value of the calc field is zero.
How can disable the button on that condition?
Thank you for your attention.

Cheers,

Roberto
 
Just wondering if you may be able to look at code effecting the 'Previous' button on the first page of a multi page form. It is greyed out when in this state, so possibly there is an 'if' condition attached to this?
 
Hi rw1, thankl you for your reply.
I agree with you, but I think there should be one more way of doing it in a simple way. A button type element can be deactivated under a condition?
 
You could also clone a template, and put your own conditional code in there to remove the submit button, or use some form Javascript to do it during page load.

To do it in JS, you would create an XX.js file (replace XX with your numeric form ID) in ./components/com_fabrik/js, with something like this:

Code:
window.addEvent('domready', function() {
   value = form_XX.formElements.get('yourtable___yourcalc').getValue().toInt();
   if (value === 0) {
      form_XX._getButton('submit').hide();
   }
});

Change form_XX to whatever the numeric ID is, like form_10. Change yourtable___yourcalc to your calc element name.

I think this should work, and is probably the simplest route.

-- hugh
 
Hello Hugh, i fallow your instructions to create the new js fiel but i got a JS error:

Uncaught TypeError: Cannot call method 'get' of undefined

Thanks for any help
 
Does this work in version 3.0.9?

I have made the 1.js file with my form number and element and tried to add an alert(value) to see what it is returning with no luck. Is there something else that is needed?
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top