0

there is an error somewhere in my code, but i cant work it out.
could one of you give it a quiq look?

<html>
<head>

<script language="JavaScript">
function bereken()
{
    j = parseInt(fx.s.value)
    p = parseInt(fx.j.value)
    s = parseInt(fx.p.value)
    while (j > 0 ) 
    {
        j = j-1
        r = (p\100)*s
        s = s+r
        ns = s
    }

    {
    document.write ("nieuwsaldo ",ns,")
    }
    window.alert ("uw nieuwe salso is"+nieuwsaldo+" euro.")
    }



</script>
</head>

<body>
<form name="fx" method="post">
<pre>
huidig saldo:        <input name="s" type="text"> 
jaren:           <input name="j" type="text"> 
rente percentage:    <input name="p" type="text">
<input type="button" name="bereken" value="Bereken" onClick="bereken()">
<pre>
</form>

</body>
</html>

Edited by mike_2000_17: Fixed formatting

2
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by wazakiller
0

Hi and welcome! Please use code tags. Generally, javascript lines end with a semicolon ( ; ), but that's not the problem now. Division is done with a forward slash ( / ) - line 13. Also, there's something wrong with your document.write. What do you want to write? And in your alert you mean ns, I guess?

Edited by twiss: n/a

0

i removed the write (din't need it)
and chanced the \ into / and changed "+nieuwsaldo+" into "+ns+" but i still have't got it working.
i suspect it has got something to do with my parseInt lines

Edited by wazakiller: n/a

0

Did you change nieuwsaldo to ns? Could you post your new code in code tags? Furthermore, if you run your code in chrome or in firefox with firebug, you can view the errors your code gives.

0

i have got it!
thanks for the fire bug tip!
the prblem was at the Fuction.

thank U!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.