Skip to content

Instantly share code, notes, and snippets.

@chathurawidanage
Created October 13, 2016 14:21
Show Gist options
  • Save chathurawidanage/e003e494d27ed76c107b7497e88e4a44 to your computer and use it in GitHub Desktop.
Save chathurawidanage/e003e494d27ed76c107b7497e88e4a44 to your computer and use it in GitHub Desktop.
DHIS2 tracker capture custom form
<p>
<input id="ZzYYXq4fJie-GQY2lXrypjO-val" name="entryfield" title="GQY2lXrypjO - MCH Infant Weight (g) - undefined" value="[MCH Infant Weight (g)]" />
</p>
<p id="bmi-text">&nbsp;</p>
<script>
$(document).ready(function(){
function setColor(color){
$("p#bmi-text").css('background-color',color);
}
function updateBMI(){
var w=$("#ZzYYXq4fJie-GQY2lXrypjO-val").val();
var bmi=Math.pow(w,2);
$("p#bmi-text").text(bmi);
if(bmi<10){
setColor('red');
}else if(bmi<20){
setColor('yellow');
}else{
setColor('green');
}
}
$("#ZzYYXq4fJie-GQY2lXrypjO-val").on('keyup',function(){
updateBMI();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment