12.1.1 Creating a CRF
For this example, a very simple CRF was created containing only three fields: Height, Weight, and BMI.
Notice that the LEFT_ITEM_TEXT contains the text that will be visible (ie Enter Height:) along with <div ID=></div>. This script provides an identifier for each field and will be referenced by the calculation script.
12.1.2 The Calculation Script
A little java-script from the JQuery library will help us perform our BMI calculation. The following should be added to the LEFT_ITEM_TEXT field within your CRF Excel template:
function calcBMI()
12.1.3 Adding A Fancy Button
The following script, when added to the RIGHT_ITEM_TEXT of the CRF Excel template, will insert a button to the right of the field:
The button has the ID “calculate1” which is referenced in the first calculation script above:$(“#calculate1”).click(function(){calcBMI(); });
Notice that the source of the image is images/Calculated.gif. This refers to the standard images folder of the OpenClinica interface. This example uses a custom image. To use a custom image, drop the file in the /oc/tomcat/webapps/OpenClinica/images folder. Alternatively, the OpenClinica images below already exist in the images folder: