Show and hide Panel on load and click on checkbox

Show and hide Panel on load and click on checkbox

March 20, 2018 PHP SugarCRM 0

 

Step1: Create one .js file in root /var/www/crm/*.js

 

function display()

{//alert('l');

document.getElementById('LBL_PANEL5').style.display = 'none';

document.getElementById('LBL_PANEL2').style.display = 'none';

document.getElementById('LBL_PANEL3').style.display = 'none';

//var f = document.getElementById('feedback_test_drive_c').value;

//var fn = document.getElementById('finance_c').value;

 

if((document.getElementById('feedback_test_drive_c').checked == true )&&( document.getElementById('finance_c').checked == true ))

{

document.getElementById('LBL_PANEL2').style.display = 'block';

document.getElementById('LBL_PANEL3').style.display = 'block';

}

else if((document.getElementById('feedback_test_drive_c').checked == true )&&( document.getElementById('finance_c').checked == false ))

{

document.getElementById('LBL_PANEL2').style.display = 'none';

document.getElementById('LBL_PANEL3').style.display = 'block';

}

else if((document.getElementById('feedback_test_drive_c').checked == false )&&( document.getElementById('finance_c').checked == true ))

{

document.getElementById('LBL_PANEL2').style.display = 'block';

document.getElementById('LBL_PANEL3').style.display = 'none';

}

if(document.getElementById('presenet_cars_c').checked == true)

{

document.getElementById('LBL_PANEL5').style.display = 'block';

}

else

{document.getElementById('LBL_PANEL5').style.display = 'none';

}

}

now,

 

Step2: include file in editview.php

 

 'includes' =>

     array (

       0 =>

       array (

         'file' => *.js',

 

       ),

),

 

step3: onload run file:

 

 array (

         'label' => '10',

         'field' => '30',

       ),

     ),

     'javascript' => '{$PROBABILITY_SCRIPT}',

     'includes' =>

     array (

       0 =>

       array (

         'file' => 'warranty.js',

 

       ),

      1 =>

      array (

     'file' => 'callpanel.js',

           ),

     ),

   'javascript' => '<script type="text/javascript" language="Javascript"> onload=display(); </script>',

   ),

   'panels' =>

   array (

     'lbl_panel5' =>

 

step4: call function on checkbox event:

 

'name' => 'feedback_test_drive_c',

           'label' => 'LBL_FEEDBACK_TEST_DRIVE',

           'displayParams' =>

           array (

             'field' =>

             array (

               'onChange' => 'display();',

             ),

           ),

 

Leave a Reply

Your email address will not be published. Required fields are marked *