lot of nulls

Discussion in 'Javascript' started by jamuna, Jan 16, 2004.

  1. jamuna

    jamuna Guest

    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?
     
    jamuna, Jan 16, 2004
    #1
    1. Advertising

  2. jamuna

    DJ WIce Guest

    : 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);
     
    DJ WIce, Jan 16, 2004
    #2
    1. Advertising

  3. "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.
     
    Richard Cornford, Jan 16, 2004
    #3
  4. jamuna

    DJ WIce Guest

    : >: 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
     
    DJ WIce, Jan 16, 2004
    #4
  5. "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.
     
    Richard Cornford, Jan 16, 2004
    #5
  6. 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.'
     
    Lasse Reichstein Nielsen, Jan 18, 2004
    #6
  7. jamuna

    DJ WIce Guest

    : <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
     
    DJ WIce, Jan 19, 2004
    #7
  8. "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.'
     
    Lasse Reichstein Nielsen, Jan 19, 2004
    #8
  9. jamuna

    DJ WIce Guest

    : > 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
     
    DJ WIce, Jan 20, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob

    Problem with nulls

    Bob, Jul 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    336
  2. Bill

    Inputting NULLS?

    Bill, Dec 11, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    374
    Suresh
    Dec 11, 2003
  3. Mike

    allow NULLS

    Mike, Jun 20, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    605
    [MSFT]
    Jun 22, 2004
  4. Angela

    Dealing with NULLs

    Angela, Jun 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    401
    Patrice
    Jun 23, 2004
  5. =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=

    Computing SQL nulls

    =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=, Jul 29, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    361
    =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=
    Jul 29, 2004
Loading...

Share This Page