G
G
gadzhi152011-03-20 16:45:25
JavaScript
gadzhi15, 2011-03-20 16:45:25

HTML + JavaScript?

Today I started learning html and javascript. I wrote a small mortgage calculator, but for some reason it does not give a result. Where did I make a mistake?

Answer the question

In order to leave comments, you need to log in

9 answer(s)
X
xdenser, 2011-03-20
@xdenser

in which books do they teach how to write (use eval)?
a = eval(form.a.value);
here the coding let us down What is it? Pascal?
? = eval(form.c.value);

s:= z/c;

X
xdenser, 2011-03-20
@xdenser

In general, I advise you to use a debugger. Firebug to the rescue. Or built into Opera or Chrome.
Well, in extreme cases, use alert in the right place.

X
xdenser, 2011-03-20
@xdenser

function calculator(form) {
var a = form.a.value;
var b = form.b.value;
var c = form.c.value;
var d = a*b/100;
var z = a+d;
var s = z/c;
form.total.value = s;
form.plat.value = d
}

this is how it should work

K
Kane, 2011-03-20
@Kane

For learning JS, I recommend getting David Flanagan's book "JavaScript. Detailed guide»
For typesetting: Andy Budd «CSS. Professional application of web-standards»

B
Barttos, 2011-03-21
@Barttos

jsbin.com/iluzu3/11
jsbin.com/iluzu3/11/edit

A
alltrash, 2011-03-20
@alltrash

This is of course hard code.
function calculator(form) {
a = eval(form.a.value);
b = eval(form.b.value);
c = eval(form.c.value);
d = a*b/100;
z = a+d;
s = z/c;
form.total.value = s;
form.plat.value = d
}

G
gadzhi15, 2011-03-20
@gadzhi15

var a = form.a.value;
varb = form.b.value;
var c = form.c.value;
var d = (a*b/100)*c;
varz = a+d;
vars = z/(c*12);
form.total.value = s;
form.plat.value = d
is more correct like this, but for some reason it does not add a and d, but simply assigns d to a. For example, a=100 d=10, z turns out to be 10010.

P
pxx, 2011-03-21
@pxx

How did people learn to program before without the Internet, habra q&a, stackoverflow and others?

D
Dan Voronov, 2011-12-04
@DanVoronov

I remember a joke that stole is mistaken only once - in choosing a profession

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question