Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > lot of nulls

Reply
Thread Tools

lot of nulls

 
 
jamuna
Guest
Posts: n/a
 
      01-16-2004
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?
 
Reply With Quote
 
 
 
 
DJ WIce
Guest
Posts: n/a
 
      01-16-2004
: 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?

eval(math.power(wynik.value,x)*pole2.value);


 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      01-16-2004
"DJ WIce" <> wrote in message
news:bu8n6s$8k0$...
>: 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?
>
> eval(math.power(wynik.value,x)*pole2.value);


Is that a joke?

Richard.


 
Reply With Quote
 
DJ WIce
Guest
Posts: n/a
 
      01-16-2004
: >: 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?
: >
: > eval(math.power(wynik.value,x)*pole2.value);
:
: Is that a joke?

sorry, I did misread. I did not see that it was pole.value = indead of
pole2.value =
my mistake.

Wouter


 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      01-16-2004
"DJ WIce" <> wrote in message
news:bu8s7i$aa7$...
>:>: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?


<URL: http://jibbering.com/faq/#FAQ4_7 >
And so:-
<URL: http://jibbering.com/faq/#FAQ4_6 >

Maybe with:-
<URL: http://jibbering.com/faq/#FAQ4_21 >
- for good measure.

>:>
>:>eval(math.power(wynik.value,x)*pole2.value);
>:
>:Is that a joke?
>
>sorry, I did misread. I did not see that it was pole.value =
>indead of pole2.value =
>my mistake.


You only recognise the one mistake?

Richard.


 
Reply With Quote
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      01-18-2004
jamuna <> writes:

> 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
--
Lasse Reichstein Nielsen -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
DJ WIce
Guest
Posts: n/a
 
      01-19-2004
: <input name="pole2" onchange="recalc(this);">...
: <input name="wynik" onchange="recalc(this);">...

Maybe onkeyup or something because in IE onchange is only triggered when the
field loses focus.

Wouter


 
Reply With Quote
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      01-19-2004
"DJ WIce" <> writes:

> : <input name="pole2" onchange="recalc(this);">...
> : <input name="wynik" onchange="recalc(this);">...
>
> Maybe onkeyup or something because in IE onchange is only triggered when the
> field loses focus.


True (as in all other browsers). However, I consider that an advantage.
Let the user type in peace, and calculate when he is done, instead of
having some other field change while he is typing.

/L
--
Lasse Reichstein Nielsen -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
DJ WIce
Guest
Posts: n/a
 
      01-20-2004
: > Maybe onkeyup or something because in IE onchange is only triggered when
the
: > field loses focus.
:
: True (as in all other browsers). However, I consider that an advantage.
: Let the user type in peace, and calculate when he is done, instead of
: having some other field change while he is typing.

Well, like is done in http://www.mattkruse.com/javascript/autocomplete/ I
don't mind if some things change (altrough it's here in the same box I'm
typing in). As long as I can type trough without change of my input (like in
the linked script).

Wouter


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
First time in one site,lot of free fun,quality DVDmovies,songs,games,drivers and lot of entertainment. nehatoor290@gmail.com C Programming 0 02-22-2009 05:57 PM
Dealing with NULLs Angela ASP .Net 1 06-23-2004 01:28 PM
allow NULLS Mike ASP .Net 8 06-22-2004 09:35 AM
Inputting NULLS? Bill ASP .Net 1 12-11-2003 07:29 PM
Problem with nulls Bob ASP .Net 0 07-02-2003 07:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57