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

  • Home
  • SEARCH
  • 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

hi i am using zend form , i created a Zend_Form_Element_Radio element that have
I am using the Zend Framework. I have a controller named 'UserController' that has
I'm having difficulty configuring Zend_Form. I have a Zend_Form sub-class. The form has some
I have created a form like this: class Form_Login extends Zend_Form { public function
I have a Zend Framework application structure as below: /application /library /Zend /Core /Filter
I have been using the Zend Framework with an MVC configuration, read about Ruby
The Zend Framework based site I have been working on is now being migrated
I have a colleague who is looking into opcode caching/Zend Acceleration (I've always assumed
What are some of the ways you have implemented models in the Zend Framework?
I'm currently building a web application (utilizing Zend Framework) and have gotten some of

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.