Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:49:24+00:00 2026-05-27T04:49:24+00:00

I am using cakephp and creating a form <?php echo $form->create(‘User’, array(‘action’ => ‘cancel’));?>

  • 0

I am using cakephp and creating a form

<?php echo $form->create('User', array('action' => 'cancel'));?>
    <fieldset>
        <?php
            echo $form->input('terms', array('type' => 'checkbox', 'label' => __('Terms and Conditions', true)));
            echo $form->hidden('security', array('value' => $security));
            echo $form->end(__('Cancel My Account', true));
        ?>
    </fieldset>

Now what i want to do is, initially keep the "Cancel My Account" button disabled and only when the checkbox is checked the button should be enabled and hence perform its respective action and similarly vice-versa. I am using the following script to check when the checkbox is checked

<script>
    $('document').ready(function(){
        $('#UserTerms').click(function() {
            var satisfied = $('#UserTerms:checked').val();
            if (satisfied != undefined) {
                $('.cancel-page div.submit input').removeAttr('disabled');
            } else {
                $('.cancel-page div.submit input').attr('disabled', 'disabled');
            }
        });
    });
</script>

But this is not working properly. The button is not getting disabled when the checkbox is unchecked. Please suggest how to make it work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:49:25+00:00Added an answer on May 27, 2026 at 4:49 am

    A suggestion, let me know if it works:

    <script type="text/javascript">
    
        // The function is defined outside the 'document ready' event
        function handleUserTermsChange() {
    
             // Save jQuery object in variable
            var $userTerms = $('#UserTerms');
    
            // Bind 'change' event to the checkbox
            $userTerms.bind('change', function() {
    
                // Save jQuery object in variable
                var $cancelAccountButton = $('.cancel-page div.submit input');
    
                 // If the checkbox is checked..
                if ($userTerms.is(':checked')) {
                    $cancelAccountButton.removeAttr('disabled');
                } else {
                    $cancelAccountButton.attr('disabled', 'disabled');
                }
    
            }).trigger('change');
        }
    
        $(document).ready(function(){
    
            // The function is called in the 'document ready' event
            handleUserTermsChange();
    
        });
    
    </script>
    
    • Its $(document), not $(‘document’) – without ”
    • No need to define the function on ‘document ready’,
      you can first define the function and then just call it on document ready.
    • Is better to use the ‘change’ event and not the ‘click’ event for check-boxes.
    • Is better to save the jQuery objects in variables before using them, this way you can always re-use them without creating them again and again
    • Is better to check if the check-box is ‘checked’ instead of checking if its not ‘undefined’.
    • .trigger(‘change’) its used to run the function once, this way we check for the initial state of the check-box (if it’s checked or not when the page loads the first time)

    Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using CakePHP, I created select-option form element with: echo $form->select('items', $numeration , array('selected' =>
I am working on a CMS using CakePHP and I want to create a
i am trying to create a Radio button using Cakephp like the one the
I'm trying to create an XML sitemap using CakePHP, from a table which has
Using cakephp: I create a website & after upload my site to main server
I am using cakephp 1.26 to create a simple message board in my localhost.
I'm creating a web application using cakephp 1.2.6. There is a functionality that I
I am using cakephp 1.3 and I want the user not to see the
I've got a small question about Creating Aro-s in Cakephp http://book.cakephp.org/#!/view/1547/Acts-As-a-Requester I'm using code
Using CakePHP's form helper to generate a checkbox is easy enough; to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.