Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java Problem

  • 13-03-2008 04:10PM
    #1
    Registered Users, Registered Users 2 Posts: 598 ✭✭✭


    I'm havint a problem with the following code:
    function CalcMORB(form){
    var m;
    z = eval(form.zapa.value)
    z = 5.91 + (0.16*z)
    m = eval(form.zapaa.value)
    m = (0.19*m)
    z = (z + m) + " %"
    form.zmorb.value = z
    return z
    }

    }
    function CalcMort(form){
    var t; var y
    z = eval(form.zapa.value)
    z = (0.1692*z)-9.065
    t = eval(form.zapaa.value)
    y = eval(form.zapat.value)
    z =(t*0.155) + z
    z = 1/(1+Math.exp(-z))
    z = Fmt(100 * z + y) + " %"
    form.zmort.value = z
    return z
    }


    function Fmt(x) {
    var v
    if(x>=0) { v=''+(x+0.05) } else { v=''+(x-0.05) }
    return v.substring(0,v.indexOf('.')+2)
    }

    And the Html Part:
    <td width="215" height="40"><div align="right"><font size="2" face="Arial">
    <input name="zmorb" type="text" class="grandvalue" value="0" size="2" />
    </font></div></td>
    <td width="215" height="40"><div align="right"><font size="2" face="Arial">
    <input name="zmort" type="text" class="grandvalue" value="0" size="2" />
    </font></div></td>

    Both of these functions are called when the person selects their age. Basically, zmort works perfectly and will update but zmorb just stays on Zero.
    If I change zmorb to be the value zmort, both the values will stay on zero. I'm a newbie to java so I'm after getting thrown in the deep end.
    Can anyone see what I'm doing wrong here?


Comments

  • Registered Users, Registered Users 2 Posts: 598 ✭✭✭arseagon


    Doh, now there's a n00b mistake. It should have been CalcMorb not CalcMORB.


  • Registered Users, Registered Users 2 Posts: 189 ✭✭MeWantBroadband


    Your problem begins with the fact that you do not know the difference between Java and Javascript.

    Do your own homework.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    The OP's post didn't break any forum rules, and there's nothing wrong with being new to programming.


Advertisement