Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Integrate JavaScript

To use JavaScript in a smartform, it is necessary to create the file custom.js. The custom.js must be enriched with smartform specific functions. After editing, this file must be uploaded to the Administration Client in the tab Resources.

Call JavaScript functions when opening and editing the form

  1. Enrich the opening <form> -tag in the HTML code with the attribute initMethod="formSpecificFunctionName".

    <form class="classname" name ="formname" security="all" initMethod="initFormSpecificFunctionName">
    </form>

  2. Enrich the custom.js file with an init function and insert all needed JavaScript functions in this function. This init function must have the same name as the name of the initMethod defined in the HTML form-tag.

    gadget.functions.initFormSpecificFunctionName = function(){
    	//do something
    }

Call JavaScript functions when saving the form

  1. Enrich the opening <form> -tag in the HTML code with the attribute validationMethod="formSpecificValidationFunctionName".

    <form class="classname" name ="formname" security="all" initMethod="initFormSpecificFunctionName" validationMethod="initValidationFormSpecificFunctionName">
    </form>

  2. Enrich the custom.js file with an init function and insert all needed JavaScript functions in this function. The validationMethod must reply either 'true' oder false'. With 'true' it is stored and with 'false' it is not stored. This init function must have the same name as the name of the validationMethod defined in the HTML form-tag.

    gadget.functions.initValidationFormSpecificValidationFunctionName= function(){
    	 if(INSERT CONDITION){
    	  // do something
              alert("data were stored!");
    	  return true;
           }
           else{
    	  // do something
    	  alert("Storing not possible!");
    	  return false;
           }
    }

  • No labels