× Form Help

How to enable and disable a submitbutton using code?

  • maikla73
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 10
  • Thank you received: 0

maikla73 created the topic: How to enable and disable a submitbutton using code?

Hello,

I searched in the forum and documentation but I didn't found what I am looking for.

I have in my form two submitbuttons.
The second one should be enabled when the first one was clicked.
In the first one is some code for a calculation and after calculation the second one should be enabled.

Is this possible and how can I do that?

Thank you very much in advance and KR
Maik
#233639
  • Posts: 5332
  • Karma: 113
  • Thank you received: 493

MarioPuco replied the topic: How to enable and disable a submitbutton using code?

Hi,

Go to your form > advanced >more options > form pieces > before form > add the following code in there :
echo '
<script>
        jQuery(document).ready(function(){
 jQuery("#YOUR-SECOND-BUTTON-ID").attr("disabled", true); 
            jQuery("#YOUR-FIRST-BUTTON-ID").on("click", function(){ 
                jQuery("#YOUR-SECOND-BUTTON-ID").attr("enable", true); 
            });
        });
    </script>
';

#YOUR-SECOND-BUTTON-ID - your second button ID
#YOUR-FIRST-BUTTON-ID - calculation button ID


This will disable your 2nd button by default.
Upon click on the first button, the second will be enabled.

Regards,
Mario

Satisfied with our Support ?
PayPal Tip
===============================================
Need to renew Pro Support?
Buy Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#233640
  • Posts: 1740
  • Karma: 62
  • Thank you received: 217

mihaela replied the topic: How to enable and disable a submitbutton using code?

Hello,

Did you already set the other submit button to be disabled on form entry?

If you have, you can simply add this line of code to the Actionscript of the first submit button element:
jQuery('#ff_elem2604').prop('disabled', null);
NOTE: You have to replace ff_elem2604 with the ID of the second submit button that you can get by inspecting that element.

Let me know whether you've managed to set this for your form and whether this is how you wanted it to work.

Regards,

Mihaela
#233641
  • maikla73
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 10
  • Thank you received: 0

maikla73 replied the topic: How to enable and disable a submitbutton using code?

Hello,

I tried this solution but it doesn't work.
When the form is shown all buttons are visible.

Do you have any idea?
echo '
<script>
        jQuery(document).ready(function(){
 jQuery("#ff_elem1012").attr("disabled", true); 
            jQuery("#ff_elem1000").on("click", function(){ 
                jQuery("#ff_elem1012").attr("enable", true); 
            });
        });
    </script>
';

Thank you and BR
Maik
#233682
  • maikla73
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 10
  • Thank you received: 0

maikla73 replied the topic: How to enable and disable a submitbutton using code?

Hello,

I just tried this version of code but it also doesn't work.
Any idea what the mistake could be?

Maybe I dont see the wood concerning too many trees. :-)
echo '
<script>
       jQuery(document).ready(function(){
 jQuery("#ff_elem1012").attr("disabled", true); 
            jQuery("#ff_elem1000").on("click", function(){ 
                jQuery("#ff_elem1012").attr("disabled", false); 
            });
        });
    </script>
';

Thank you in advance and KR
Maik
#233694
  • Posts: 5332
  • Karma: 113
  • Thank you received: 493

MarioPuco replied the topic: How to enable and disable a submitbutton using code?

Hi,

By default this wont hide the button but rather it will disable it, but no worries we can do it the way you want it:
echo '
<script>
       jQuery(document).ready(function(){
 jQuery("#ff_elem1012").css("display", "none"); 
            jQuery("#ff_elem1000").on("click", function(){ 
                jQuery("#ff_elem1012").css("display", "block"); 
            });
        });
    </script>
';

Test it out and let me know if it works now.

Regards,
Mario

Satisfied with our Support ?
PayPal Tip
===============================================
Need to renew Pro Support?
Buy Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#233696
Moderators: ForumSupporttomeperica
Time to create page: 0.056 seconds

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here