lot of nulls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jamuna

    lot of nulls

    setInterval('wi th(document.for m)pole.value = pole2.value*wyn ik.value',200)
    it returns me some big number with a lot of nulls after point.
    how to .... it?
  • DJ WIce

    #2
    Re: lot of nulls

    : setInterval('wi th(document.for m)pole.value = pole2.value*wyn ik.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);


    Comment

    • Richard Cornford

      #3
      Re: lot of nulls

      "DJ WIce" <contextmenu@dj wice.com> wrote in message
      news:bu8n6s$8k0 $1@news.tudelft .nl...[color=blue]
      >: setInterval('wi th(document.for m)pole.value = pole2.value*wyn ik.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);[/color]

      Is that a joke?

      Richard.


      Comment

      • DJ WIce

        #4
        Re: lot of nulls

        : >: setInterval('wi th(document.for m)pole.value = pole2.value*wyn ik.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


        Comment

        • Richard Cornford

          #5
          Re: lot of nulls

          "DJ WIce" <contextmenu@dj wice.com> wrote in message
          news:bu8s7i$aa7 $1@news.tudelft .nl...[color=blue]
          >:>:setInterval ('with(document .form)pole.valu e = pole2.value*
          >:>:wynik.value ',200)
          >:>:it returns me some big number with a lot of nulls after point.
          >:>:how to .... it?[/color]

          <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.
          [color=blue]
          >:>
          >:>eval(math.po wer(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.[/color]

          You only recognise the one mistake?

          Richard.


          Comment

          • Lasse Reichstein Nielsen

            #6
            Re: lot of nulls

            jamuna <jamuna@ask.m e> writes:
            [color=blue]
            > setInterval('wi th(document.for m)pole.value = pole2.value*wyn ik.value',200)
            > it returns me some big number with a lot of nulls after point.
            > how to .... it?[/color]

            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.f orms['form']) {
            elements.pole.v alue = elements.pole2. value * elements.wynik. value;
            }

            2) Personally, I wouldn't use "with". Just do:
            var elems = document.forms['form'].elements;
            elems.pole.valu e = elems.pole2.val ue * elems.wynik.val ue;"

            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(elem s['pole2'].value * elems['wynik'].value);
            // ^^^^^ rounds to nearest integer, so no more zeroes.
            }
            </script>
            </script>
            <form ...>...
            <input name="pole">...
            <input name="pole2" onchange="recal c(this);">...
            <input name="wynik" onchange="recal c(this);">...
            </form>

            Good luck
            /L
            --
            Lasse Reichstein Nielsen - lrn@hotpop.com
            DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
            'Faith without judgement merely degrades the spirit divine.'

            Comment

            • DJ WIce

              #7
              Re: lot of nulls

              : <input name="pole2" onchange="recal c(this);">...
              : <input name="wynik" onchange="recal c(this);">...

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

              Wouter


              Comment

              • Lasse Reichstein Nielsen

                #8
                Re: lot of nulls

                "DJ WIce" <contextmenu@dj wice.com> writes:
                [color=blue]
                > : <input name="pole2" onchange="recal c(this);">...
                > : <input name="wynik" onchange="recal c(this);">...
                >
                > Maybe onkeyup or something because in IE onchange is only triggered when the
                > field loses focus.[/color]

                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 - lrn@hotpop.com
                DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                'Faith without judgement merely degrades the spirit divine.'

                Comment

                • DJ WIce

                  #9
                  Re: lot of nulls

                  : > 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


                  Comment

                  Working...