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 6179397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:39:21+00:00 2026-05-24T00:39:21+00:00

I have a Zend form that has two checkboxes, if the first is unchecked

  • 0

I have a Zend form that has two checkboxes, if the first is unchecked the second should be disabled.

The two elements are:

    $element = $this->createElement('checkbox','show_assessments');
    $element->setLabel('Do you want to view assessments?');
    $element->setAttrib('onchange', 'javascript:toggleElement("show_assessments", "show_expired")');
    $element->clearDecorators();
    $element->addDecorator('StandardTable');
    if($preferences['show_assessments'])
        $element->setValue(1);
    $this->addElement($element);
    $this->_elementNames[] = 'show_assessments';

    $element = $this->createElement('checkbox','show_expired');
    $element->setLabel('Include expired programs?');
    if(!$preferences['show_assessments'])
        $element->setAttrib('disable', true);
    $element->clearDecorators();
    $element->addDecorator('StandardTable');
    if($preferences['show_expired'])
        $element->setValue(1);
    $this->addElement($element);
    $this->_elementNames[] = 'show_expired';

and my Javascript function to toggle the elements is:

    function toggleElement(sender, receiver)
    {
        if (!sender || !receiver) return;
            if ($('#'+sender).is(':checked'))
            {
                    $('#'+receiver+' :input').removeAttr('disabled');
                    alert(receiver+' is now enabled');
            }
            else
            {
                    $('#'+receiver+' :input').attr('disabled', true);
                    alert(receiver+' is now disabled');
            }
            if ($('#'+receiver).is('checked'))
                    alert(receiver+' is checked');
            else
                    alert(receiver+' is not checked');
    } 

The problem is that the last if statement, checking if receiver is checked, is false no matter what, and receiver is never toggled. Any ideas?

Edit:

It seems to always have a problem with the second element. I tried reversing it, so show_expired was the sender and show_assessments was the receiver and this time it could tell when show_expired was checked, but couldn’t tell for show_assessments.

  • 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-24T00:39:22+00:00Added an answer on May 24, 2026 at 12:39 am

    Got it to work without jQuery

    function toggleElement(sender, receiver)
    {
    var sendEl = document.getElementById(sender);
    var recEl = document.getElementById(receiver);
    if (sendEl.checked)
        recEl.disabled = false;
    else
        recEl.disabled = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one user_form class that extends zend form, it has 4 elements
About to create a form using Zend Form, all the form elements should have
If I have a form element that has multiple validators attached to it (3
hi i am using zend form , i created a Zend_Form_Element_Radio element that have
I have the Zend Form with some elements. And I need to placing some
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I am working on zend. I have a form with some checkboxes. I want
I have a zend form that I'm initializing as follows: $form = new Form_XYZ();
I have created one form that extends zend form. For Adding New Record it
I have a form made by Zend Framework that needs a submit button. I

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.