jamuna said:
setInterval('with(document.form)pole.value = pole2.value*wynik.value',200)
it returns me some big number with a lot of nulls after point.
how to .... it?
Code is *not* obvious, especially when you say that it is not doing
what you want ... so: What are you trying to do?
Also, if we can't reproduce the problem, it's hard to know when it is
fixed. What numbers have you entered into the form controls pole2 and
wynik?
My *guess* is that you want to keep one form cell's value updated with
the multiplum of two other cells' values. How many decimals do you
want?
There are several promblems with the method you use:
1) Addressing form controls. For consistent access to forms across
browsers, and also compliance with W3C DOM, you should use the
collections document.forms and form.elements.
So:
with(document.forms['form']) {
elements.pole.value = elements.pole2.value * elements.wynik.value;
}
2) Personally, I wouldn't use "with". Just do:
var elems = document.forms['form'].elements;
elems.pole.value = elems.pole2.value * elems.wynik.value;"
3) It's inefficient to constantly change the content of the "pole"
control. You can trigger the recalculation only when you have changed
on of the other controls.
My suggestion:
<script type="text/javascript">
function recalc(form) {
var elems = form.elements;
elems['pole'].value =
Math.round(elems['pole2'].value * elems['wynik'].value);
// ^^^^^ rounds to nearest integer, so no more zeroes.
}
</script>
</script>
<form ...>...
<input name="pole">...
<input name="pole2" onchange="recalc(this);">...
<input name="wynik" onchange="recalc(this);">...
</form>
Good luck
/L