0

I am new to magento and using magento 1.9 version.

I want show/Hide adminpanel form field based on the other checkbox is checked.

How to do this using javascript.

-1

As an example you have two field:

$checkbox = $fieldset->addField('name', 'checkboxes', array('label' => 'check', 'name' => 'name[]',
    'values' => array(
        array('value'=>'1', 'label'=>'1'),
        array('value'=>'2', 'label'=>'2'),
        array('value'=>'3', 'label'=>'3'),
        array('value'=>'4', 'label'=>'4'),
        array('value'=>'5', 'label'=>'5'),
    )
));

    $another_field=$fieldset->addField('another_field','textarea',array(
                'label' => Mage::helper('module')->__('Another Field'),
                'name' =>  'another_field',
                'required'=>true,
                'style'=>'width:600px;height:100px;'
    ));

    $this->setChild('form_after',$this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
                ->addFieldMap($checkbox->getHtmlId(),$checkbox->getName())
                ->addFieldMap($another_field->getHtmlId(),$another_field->getName())
    ->addFieldDependence($another_field->getName(),$checkbox->getName(),1) );

From above code if 1 checkbox checked then textarea will be visible.

|improve this answer|||||
  • @SaravananDS if it helps you please mark is accepted so in future it will be helpful for others – Prashant Valanda Nov 17 '16 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.