Magento – how to show and hide field in magento admin form on change function

magento-1.8

i need to hide form field on on change in magento admin.
I need to know that how can i show hide field with his labels in magento admin form
my form

$fieldset->addField('style_content', 'select', array(
            'label' => Mage::helper('magazine')->__('Select available Slider Styles'),
            'name' => 'style_content',           
            'values' => array(
                array(
                    'value' => 'Yes',
                    'label' => Mage::helper('magazine')->__('Yes'),
                ),
                array(
                    'value' => 'No',
                    'label' => Mage::helper('magazine')->__('No'),
                ),
            ),
            'onchange'  => 'onchangeStyleShow()',
        ));

Best Answer

magento is provide to add JavaScript function on admin form using setAfterElementHtml where you can right your custom script.

$field->setAfterElementHtml('<script>
 function onchangeStyleShow(){
// here goes your custom Javascript
}
</script>');