electricphp
Programmer
I have the following function which is not outputting anything when I'm calling it:
The part that's supposed to output the percentile is this:
but it's not outputing anything
any help would be appreciated
Code:
<script language=JAVASCRIPT type="TEXT/JAVASCRIPT">
<!-- Hide script from older browsers
function percentiles(sex,age,value) {
if (sex == 2) {
var percentiles_array = girls_bmi;
} else {
var percentiles_array = boys_bmi;
}
for (var i = 0; i < percentiles_array.length; i ++) {
data = percentiles_array[i];
details = data.split("|");
details_age = details[0];
if (age == details_age) {
var L = details[1];
var M = details[2];
var S = details[3];
break;
}
}
if(L==0) {
Z = log(value/M)/S
} else {
Z = (Math.pow((value/M),L)-1)/(L*S)
}
P=1-1/Math.sqrt(2*3.14159265)*Math.exp(-Math.pow(Math.abs(Z),2)/2)*(0.4361836*(1/(1+0.33267*Math.abs(Z)))-0.1201676*Math.pow((1/(1+0.33267*Math.abs(Z))),2)+0.937298*Math.pow((1/(1+0.33267*Math.abs(Z))),3))
if(Z>0) {
centile = P*100
} else {
centile = 100-P*100
}
return Math.round(centile*10)/10
}
// End hiding script -->
</script>
The part that's supposed to output the percentile is this:
Code:
<script language=JAVASCRIPT type="TEXT/JAVASCRIPT">
percentile = percentiles(1, 5, 19);
percentile = parseInt(percentile);
document.write("percentile: " + percentile);
</script>
but it's not outputing anything
any help would be appreciated