1. Member
Join Date
Oct 2012
Posts
3

## it's math related!

hi everyone...i'm new here...

probability=1/(1+(EXP((1.059)-(A8*1.37)+(-2.578*B8)+(-0.568*C8)+(0.987*D8)+(0.987*E8)+(1.205*F8)+(-1.795*G8)+(-0.645*H8))))

?? in php

i need to know it very badly!!

i'm calculating the probability of a person to have hypertension. . .

letterrs A-H stands for kasarian,weight, heredity, exercise, softdrink, likor, smoke, pork... accordingly ... i need to submit my system the very next week...

hope can get answers from you ASAP guys!! thanks in advance... God bless..

2. Registered User
Join Date
Nov 2010
Posts
1,276
I'm guessing that you would make user inputs, get their values, assign them to variables A8 to H8, place that line of code, then output probability to the page

what are you stuck on?

3. Member
Join Date
Oct 2012
Posts
3
function calculate()
{
var ka = parseFloat(document.hyp_frm.kasarian.value);
var wt = parseFloat(document.hyp_frm.weight.value);
var he = parseFloat(document.hyp_frm.heredity.value);
var ex = parseFloat(document.hyp_frm.exercise.value);
var so = parseFloat(document.hyp_frm.softdrink.value);
var li = parseFloat(document.hyp_frm.likor.value);
var sm = parseFloat(document.hyp_frm.smoke.value);
var po = parseFloat(document.hyp_frm.pork.value);
if (document.hyp_frm.kasarian.value == "0") {ka = ka * (1.37);}
if (document.hyp_frm.weight.value == "0") {wt = wt * (-2.578);}
if (document.hyp_frm.heredity.value == "0") {he = he * (-0.568);}
if (document.hyp_frm.exercise.value == "0") {ex = ex * (0.987);}
if (document.hyp_frm.softdrink.value == "0") {so = so * (0.987);}
if (document.hyp_frm.likor.value == "0") {li = li * (1.205);}
if (document.hyp_frm.smoke.value == "0") {sm = sm * (-1.795);}
if (document.hyp_frm.pork.value == "0") {po = po * (-0.645);}
pro="1/1+(EXP((1.059)-(1.37 * ka)+(-2.578 * wt)+(-0.568*he)+(0.987*ex)+(0.987*so)+(1.205*li)+(-1.795*sm)+(-0.645*po)))";
document.getElementById(sub3).value=pro;
}

This is the code i'm using and it simply didnt work....

I guess the problem is in the exponent(EXP)...do you have any idea how to make it work?

4. Modified in next post
Last edited by JMRKER; 10-17-2012 at 01:06 PM.

5. Assuming it is the natural logarithm you are trying to convert from Excel,
the equivalent javascript command would be log() and/or pow().
See: http://www.w3schools.com/jsref/jsref_log.asp
Code:
```<script type="text/javascript">
</script>```