Knowledge Base - How to use the custom JS function?

"I installed the plugin. I would like to know how to use the javascript function? customCategoriesAction_1"

 

Hello, this is a full custom function you can use and implement how you need. This js function is called on the onChange event of the category list (customCategoriesAction_1 for category 1, ..., customCategoriesAction_5 for category 5).

For exemple, for a customer we have set this code in entry form to show/hide some fields depending the category selection:

$js = "\n" .
"<script type=\"text/javascript\">" .
"<!-- \n\n".
"/* <![CDATA[ */ \n\n".
"\n\t function customCategoriesAction_1(list) {  ".
"\n\t\t document.getElementById('groupe_1').style.display = 'none' ; " .
"\n\t\t document.getElementById('groupe_2').style.display = 'none' ; " .
"\n\t\t document.getElementById('groupe_3').style.display = 'none' ; " .
"\n\t\t idcat = list.value ; " ;

$js.= "\n\t\t if(idcat == '3'){ document.getElementById('groupe_1').style.display = 'block' ; } " ;

$js.= "\n\t\t if(idcat == '34'){ document.getElementById('groupe_2').style.display = 'block' ; } " ;
$js.= "\n\t\t if(idcat == '33'){ document.getElementById('groupe_3').style.display = 'block' ; } " ;

$js.= "\n\t }" .

"\n\t /* ]]> */" .
"\n\t // -->" .
"\n</script>";
$config->addCustomHeadTag($js);

If you dont need any custom functiom, simply dont use the custom script option.

Applies To

All Products