Disable Drop-box Based On Users Selection

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

    #16
    Re: Disable Drop-box Based On Users Selection

    "Randy Webb" <hikksnotathome @aol.com> wrote in message
    news:n8ednWgETM McDJHdRVn-hQ@comcast.com. ..
    <snip>[color=blue][color=green]
    >>I think we start with reliable. From there on we are clearly
    >>into the realms of opinion, and we have:-[/color]
    >[color=green]
    >> 1. W3C HTML DOM conformance favouring the longer version
    >> (though it is ambiguous whether it should allow the
    >> shorthand of referring to the elements as named members
    >> of the form, I still think it should).[/color]
    >
    >Fair enough, even though I personally thing too much
    >weight/discussion is given to W3C, ECMAScript, or any
    >other "regulating body". <shrug>[/color]

    I don't think we can get away from ECMA 262, its algorithms define what
    is "correct" for the language. Not that there is much that can be done
    if an interpreter is identified as objectively wrong. There are also
    job/task specifications that vaguely call for coding to conform to
    "applicable web standards" so there is some value in knowing what those
    standards are, and their implications.
    [color=blue][color=green]
    >>2. Clarity in source code, favouring the longer version.[/color]
    >
    >See my reply to Lasse, with regards to + versus parseInt.
    >Every one of us is quick to point out that its "better" to
    >use + because it is marginally faster.[/color]

    Incidentally, for clarity I usually wrap unary + operations in
    parenthesise.
    [color=blue]
    >Now, we are all saying "No, faster isn't better, clarity is" ???[/color]

    I think we are saying that when initially presenting the subject clarity
    is better. But from then on an explanation including aspects like
    efficient use (possibly of alternatives) would not be out of place.
    Giving people enough to make informed decisions for themselves seems
    like the ideal approach, unfortunately that will usually be impractical
    within the quick answers section of the FAQ.

    <snip>[color=blue]
    >In reality, none of the speed matters.[/color]

    I don't think I would consider it good style to write inefficient code
    without some other definite justification for doing so. But the
    comprehensibili ty for collages[1] of the resulting code would be one
    justification, so long as the result wasn't ridiculously inefficient.
    [color=blue]
    >Not with +, form references, or any other methods.
    >Not even eval <shudder>. If any one of us made a simple test
    >page that used all of the available ways to convert from a
    >string to a number, one time, none of us could see a difference.[/color]

    Human reaction time is about 0.4 seconds so anything that happens
    quicker than that is going to be difficult to perceive. With code the
    relevance of efficiency comes down to how all of the individual
    imperceptibly fast statements add up.
    [color=blue]
    >But thats beside the point (Or not at least
    >until you get into real heavy dHTML apps).[/color]

    Maybe the value in discussing and promoting fast implementation in
    JavaScript is so that bad habits that are insignificant in form
    validation code are not carried over into DHTML where they might serve
    to cripple the code on slower systems?

    <snip>[color=blue][color=green]
    >>... . The entry could have additional notes mentioning ...[/color][/color]
    <snip>[color=blue]
    >As long as notes are made that with a NAME attribute that
    >either way works and that the shorthand is marginally
    >faster, its fine.[/color]

    If you are satisfied with those conditions I will have a go at writing
    those notes.
    [color=blue][color=green]
    >>I notice that you didn't quote the modified 4.13, do I take
    >>that as implying that you would prefer not to merge this with
    >>the existing 4.13 question? (I quite liked that idea)[/color]
    >
    >I think you are asking if I like the
    >idea of merging the two, and I do.[/color]

    I was, and good! That is the way I will go, unless anyone objects.
    [color=blue]
    >Might be better in 4.39 where it already
    >discusses bracket notation though.[/color]

    My page, linked to from 4.39, has an example of the shortcut form
    accessor. At the time I didn't want to use that example but I needed a
    common and recognisable accessor that wasn't too complex for the
    example. But I don't think 4.39 (and the related document) is
    appropriate for a discussion about forms and accessing them
    specifically. Better if it sticks with the square bracket syntax in
    general.
    [color=blue]
    >Either place, or even linked to a website about it. I just
    >think it should be explained (both ways, along with both ways
    >advantages/drawbacks) how to access a form and its elements in
    >the FAQ. And then let the script author decide whether they want
    >clarity or speed.[/color]

    I didn't want to get into writing notes on form access because of all of
    the other issues that equally deserve coverage. The alternative
    accessors and their merits/drawbacks are relatively easy in comparison
    with the ID/XHTML issues, but it looks like I am going to have to.

    Richard.

    [1] That only applies to colleges who would understand JavaScript
    anyway. Colleges who understand only other languages have no right to
    expect me to write:-

    var divStyle = (div && div.style) ? div.style : div;

    - instead of -

    var disStyle = (div && div.style) || div;

    -just because in their languages the result of the second expression
    would be boolean not an object reference. Even though the code that
    followed the second statement would be initially incomprehensibl e to a
    programmer only familiar with, say, Java, as they would be surprised to
    find the boolean result they expected being treated as an object.


    Comment

    • Richard Cornford

      #17
      Re: Disable Drop-box Based On Users Selection

      "Dr John Stockton" <spam@merlyn.de mon.co.uk> wrote in message
      news:R2TYhOJvy9 CAFw77@merlyn.d emon.co.uk...
      <snip>[color=blue]
      >ISTM, therefore, that it would be well to give the above as
      > Frm = document.forms['formName']
      > Ele = Frm.elements['elementName']
      >or similar, to give the clue that Frm can be used for
      >getting other elements.[/color]

      In most cases when I want to reference multiple form elements (might
      have to start calling them controls in the FAQ from now on) I assign a
      reference to the form's elements collection to a local variable so that
      it does not need to be re-resolved as a member of the form.
      [color=blue]
      >Re FAQ 4.13 link : IIRC, that was a good one; or, more globally,
      >the third link in 3.2, http://devedge.netscape.com/library/manuals/
      >2000/java script/1.3/reference/, is/was good - better than
      >the 1.5 version, provided that it is used with care.[/color]

      That's a good point. I will try and keep the reference to the 1.3 doce
      in somewhere.
      [color=blue]
      >I suspect that it may be worth-while using a links-checker on
      >the FAQ from time to time; those not found can be given a
      >temporary "where is it" mark.[/color]

      Jim's scripts check the references when they build the page (and
      apparently style them differently in the HTML version if not found). But
      I will be (have been) verifying them anyway ( I have already found that
      the second in 2.3 is apparently no longer there).
      [color=blue]
      >If the FAQ is getting a complete make-over, ISTM that it might
      >be worth classifying the contents of Sec. 4 by topics (which
      >wasn't necessary when it started).[/color]

      Unfortunately it isn't that simple as reordering section 4 would throw
      off all of the references to it in the archives (the anchors are
      generated dynamically from the order in the XML) and on the whole I
      think that sacrificing the usefulness of the archives is something I
      don't want to do right now.

      Given enough time it might be possible to re-do the scripts and XML
      format to avoid that problem, but I should probably get this revision
      complete first.

      Richard.


      Comment

      • Jim Ley

        #18
        Re: Disable Drop-box Based On Users Selection

        On Tue, 20 Jan 2004 08:30:42 -0000, "Richard Cornford"
        <Richard@litote s.demon.co.uk> wrote:
        [color=blue]
        >Unfortunatel y it isn't that simple as reordering section 4 would throw
        >off all of the references to it in the archives (the anchors are
        >generated dynamically from the order in the XML) and on the whole I
        >think that sacrificing the usefulness of the archives is something I
        >don't want to do right now.[/color]

        This was a severe oversight on my part, in retrospect I should not
        have used numbers, but named faq's for the quick answers when I took
        over.

        Jim.
        --
        comp.lang.javas cript FAQ - http://jibbering.com/faq/

        Comment

        • Dr John Stockton

          #19
          Re: Disable Drop-box Based On Users Selection

          JRS: In article <_9CdnWSTNKp18J HdRVn-uQ@comcast.com> , seen in
          news:comp.lang. javascript, Randy Webb <hikksnotathome @aol.com> posted at
          Mon, 19 Jan 2004 18:52:09 :-[color=blue]
          >Lasse Reichstein Nielsen wrote:[color=green]
          >> Randy Webb <hikksnotathome @aol.com> writes:
          >>
          >>[color=darkred]
          >>>Now, do we recommend clarity, or speed?[/color]
          >>
          >>
          >> In a FAQ: Clarity, without exception.
          >> Speed at most gets a foot note.[/color]
          >
          >Then why do we recommend +varName to convert to a number when
          >parseInt/parseFloat(varN ame) is more concise?[/color]

          They can seem more concise only to those who do not know the meaning of
          the word, as given by Oxford & Webster. They might be considered more
          explicit.

          It seems impossible to express an action more concisely than by a single
          character; and + is easy to explain because the whole operand is a
          standard number (or 0x<hex>) and there is no need to go into the
          termination condition.

          --
          © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
          <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
          <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
          <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

          Comment

          • Randy Webb

            #20
            Re: Disable Drop-box Based On Users Selection

            Dr John Stockton wrote:
            [color=blue]
            > JRS: In article <_9CdnWSTNKp18J HdRVn-uQ@comcast.com> , seen in
            > news:comp.lang. javascript, Randy Webb <hikksnotathome @aol.com> posted at
            > Mon, 19 Jan 2004 18:52:09 :-
            >[color=green]
            >>Lasse Reichstein Nielsen wrote:
            >>[color=darkred]
            >>>Randy Webb <hikksnotathome @aol.com> writes:
            >>>
            >>>
            >>>
            >>>>Now, do we recommend clarity, or speed?
            >>>
            >>>
            >>>In a FAQ: Clarity, without exception.
            >>>Speed at most gets a foot note.[/color]
            >>
            >>Then why do we recommend +varName to convert to a number when
            >>parseInt/parseFloat(varN ame) is more concise?[/color]
            >
            >
            > They can seem more concise only to those who do not know the meaning of
            > the word, as given by Oxford & Webster. They might be considered more
            > explicit.[/color]

            Point taken, and I will make note of it next time, to look up all words
            that I use in the dictionary.

            As for a definition, the dictionary I use defines explicit as:

            1 a : fully revealed or expressed without vagueness, implication, or
            ambiguity : leaving no question as to meaning or intent <explicit
            instructions>

            And you are indeed correct that its a more explicit word to use.
            [color=blue]
            > It seems impossible to express an action more concisely than by a single
            > character; and + is easy to explain because the whole operand is a
            > standard number (or 0x<hex>) and there is no need to go into the
            > termination condition.[/color]

            Your argument is that +varName leaves less question as to meaning than
            using Number(varName) does?

            The plus sign has two uses in javascript, the Number function only has
            one. Fewer uses means less confusion, less confusion leads to explicity.


            --
            Randy
            Chance Favors The Prepared Mind

            Comment

            • Lasse Reichstein Nielsen

              #21
              Re: Disable Drop-box Based On Users Selection

              Randy Webb <hikksnotathome @aol.com> writes:
              [color=blue]
              > The plus sign has two uses in javascript, the Number function only has
              > one.[/color]

              Actually Number has two uses. The first is a converter to the number
              type (Number("42")), the other is as a constructor for number
              *objects* (new Number(42)).

              For the plus sign, I think you added the wrong way. "1" + "1" is not two,
              but 11 (at least it is a lot more than two :). The uses I can remember:
              Prefix sign/conversion
              Infix number addition
              Infix string concatentation
              Optional sign on exponent of numbers in scientific notation (e.g. 864E+5)
              In pre-increment ++
              in post-increment ++
              As repetition in regular expressions
              [color=blue]
              > Fewer uses means less confusion, less confusion leads to explicity.[/color]

              I concur.
              /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

              • Dr John Stockton

                #22
                Re: Disable Drop-box Based On Users Selection

                JRS: In article <LbOdnT7bZ7XMJ5 DdRVn-hw@comcast.com> , seen in
                news:comp.lang. javascript, Randy Webb <hikksnotathome @aol.com> posted at
                Tue, 20 Jan 2004 18:30:34 :-[color=blue]
                >[color=green]
                >> It seems impossible to express an action more concisely than by a single
                >> character; and + is easy to explain because the whole operand is a
                >> standard number (or 0x<hex>) and there is no need to go into the
                >> termination condition.[/color]
                >
                >Your argument is that +varName leaves less question as to meaning than
                >using Number(varName) does?[/color]

                No. Perhaps you still have not looked up "concise".
                [color=blue]
                >The plus sign has two uses in javascript, the Number function only has
                >one. Fewer uses means less confusion, less confusion leads to explicity.[/color]

                The second sentence, apart from having an unknown word, is generally
                true. The plus sign has three distinct uses : binary, with at least one
                string operand, is concatenation; binary, with two numbers, is addition;
                unary is return a number.

                But the binary operator + is very well known in arithmetic - it is
                probably still taught in schools - and the unary is almost as well
                known; the presence, in code, of a + that can only be a unary + should
                cause no difficulty whatsoever in the second and subsequent occasions
                when one is seen.

                On the first occasion, there may be surprise; but, on the presumption
                that it serves a purpose, there is only one reasonable interpretation :
                that the result is a number.

                --
                © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
                <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

                Comment

                • Randy Webb

                  #23
                  Re: Disable Drop-box Based On Users Selection

                  Richard Cornford wrote:
                  [color=blue]
                  > "Randy Webb" <hikksnotathome @aol.com> wrote in message
                  > news:n8ednWgETM McDJHdRVn-hQ@comcast.com. ..
                  > <snip>
                  >[color=green][color=darkred]
                  >>>I think we start with reliable. From there on we are clearly
                  >>>into the realms of opinion, and we have:-[/color]
                  >>[color=darkred]
                  >>>1. W3C HTML DOM conformance favouring the longer version
                  >>> (though it is ambiguous whether it should allow the
                  >>> shorthand of referring to the elements as named members
                  >>> of the form, I still think it should).[/color]
                  >>
                  >>Fair enough, even though I personally thing too much
                  >>weight/discussion is given to W3C, ECMAScript, or any
                  >>other "regulating body". <shrug>[/color]
                  >
                  >
                  > I don't think we can get away from ECMA 262, its algorithms define what
                  > is "correct" for the language. Not that there is much that can be done
                  > if an interpreter is identified as objectively wrong. There are also
                  > job/task specifications that vaguely call for coding to conform to
                  > "applicable web standards" so there is some value in knowing what those
                  > standards are, and their implications.[/color]

                  Arguing ECMA is the same as arguing form access. We can both argue until
                  Hades freezes over about it. We are both right and both wrong (in
                  different regards). While we are waiting for the freeze, we can even
                  argue whether Hades exists or not.

                  For the record, the FAQ should use the longhand notation. For more
                  reasons than speed, but shorthand will always beat it speed-wise. Agreed?


                  <--snip-->
                  [color=blue]
                  > Maybe the value in discussing and promoting fast implementation in
                  > JavaScript is so that bad habits that are insignificant in form
                  > validation code are not carried over into DHTML where they might serve
                  > to cripple the code on slower systems?[/color]

                  Good point.
                  [color=blue]
                  > <snip>
                  >[color=green][color=darkred]
                  >>>... . The entry could have additional notes mentioning ...[/color][/color]
                  >
                  > <snip>
                  >[color=green]
                  >>As long as notes are made that with a NAME attribute that
                  >>either way works and that the shorthand is marginally
                  >>faster, its fine.[/color]
                  >
                  >
                  > If you are satisfied with those conditions I will have a go at writing
                  > those notes.
                  >[/color]

                  See above :) But I do think the speed should be mentioned. If for no
                  other reason than completeness.
                  [color=blue][color=green][color=darkred]
                  >>>I notice that you didn't quote the modified 4.13, do I take
                  >>>that as implying that you would prefer not to merge this with
                  >>>the existing 4.13 question? (I quite liked that idea)[/color]
                  >>
                  >>I think you are asking if I like the
                  >>idea of merging the two, and I do.[/color]
                  >
                  >
                  > I was, and good! That is the way I will go, unless anyone objects.[/color]

                  No objections :)

                  --
                  Randy
                  Chance Favors The Prepared Mind

                  Comment

                  • Richard Cornford

                    #24
                    Re: Disable Drop-box Based On Users Selection

                    "Randy Webb" <hikksnotathome @aol.com> wrote in message
                    news:h4WdnWgYt4 LIjpLdRVn-jw@comcast.com. ..
                    <snip>[color=blue]
                    >For the record, the FAQ should use the longhand notation.
                    >For more reasons than speed,
                    >but shorthand will always beat it speed-wise. Agreed?[/color]

                    The mechanics of property accessor resolution mean that the shorthand
                    accessors will always be resolved quicker than the longer versions.

                    <snip>[color=blue]
                    >... But I do think the speed should be mentioned.
                    >If for no other reason than completeness.[/color]

                    Completeness, an unfortunate paradox: the more complete the less chance
                    of finishing. :)

                    Yes I will mention the existence of the shorthand accessors and the
                    relative speeds of resolution. But I will also mention storing a form
                    (and/or elements collection) reference as a local variable for
                    efficiency when referencing multiple form controls.

                    I have been looking at the number formatting functions in 4.6 recently
                    but I will start working on a revised 4.13 shortly.

                    Incidentally, as 4.6 is going to be chanced to a more general number to
                    formatted string question and have a separate page of notes there will
                    be room for quite a few examples of number formatting functions. So if
                    anyone has any favourite useful number formatting functions they would
                    like to contribute I would appreciate seeing them.

                    Richard.


                    Comment

                    • Dr John Stockton

                      #25
                      Re: Disable Drop-box Based On Users Selection

                      JRS: In article <bun998$gss$1$8 300dec7@news.de mon.co.uk>, seen in
                      news:comp.lang. javascript, Richard Cornford
                      <Richard@litote s.demon.co.uk> posted at Thu, 22 Jan 2004 01:33:27 :-
                      [color=blue]
                      >Incidentally , as 4.6 is going to be chanced to a more general number to
                      >formatted string question and have a separate page of notes there will
                      >be room for quite a few examples of number formatting functions. So if
                      >anyone has any favourite useful number formatting functions they would
                      >like to contribute I would appreciate seeing them.[/color]

                      function LZ(x) {return(x<0||x> 9?"":"0")+x}

                      function LZZ(x) {return(x<0||x> 99?""+x:"0"+LZ( x))}

                      // Note that those *always* return strings, and the strings *always*
                      represent the right value, which *might* reduce undetected error.

                      function Prfx(Q, L, c) { var S = Q+"" // ??
                      // if (!c) var c = ' '
                      if (c.length>0) while (S.length<L) { S = c+S } ;
                      return S }

                      and anything else recommended in



                      --
                      © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                      <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                      <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
                      <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

                      Comment

                      • Richard Cornford

                        #26
                        Re: Disable Drop-box Based On Users Selection

                        "Dr John Stockton" <spam@merlyn.de mon.co.uk> wrote in message
                        news:RUU4ZPN1y+ DAFwBN@merlyn.d emon.co.uk...
                        <snip>[color=blue]
                        > function LZ(x) {return(x<0||x> 9?"":"0")+x}
                        >
                        > function LZZ(x) {return(x<0||x> 99?""+x:"0"+LZ( x))}
                        >
                        > // Note that those *always* return strings, and the strings *always*
                        > represent the right value, which *might* reduce undetected error.
                        >
                        > function Prfx(Q, L, c) { var S = Q+"" // ??
                        > // if (!c) var c = ' '
                        > if (c.length>0) while (S.length<L) { S = c+S } ;
                        > return S }[/color]

                        Thanks for those.

                        While I was looking at the handling of numbers for formatting I noticed
                        that IE 4 does not have isNaN and isFinite but it struck me that NaN and
                        Infinity would probably want special handling under some circumstances
                        (maybe not often) and I wondered whether it would be worth emulating
                        them for IE 4 (and maybe some others). These are the functions that I
                        thought might be practical for the task:-

                        if(typeof isNaN != 'function'){
                        isNaN = function(n){
                        n = (+n);
                        /* NaN does not equal itself and should be the only number
                        for witch the type-converting equality test returns
                        false. So return NOT the result of the comparison:
                        */
                        return !(n == n);
                        };
                        }
                        if(typeof isFinite != 'function'){
                        /* isFinite requires isNaN */
                        isFinite = function(n){
                        /* If the number is NaN return false, else if it is not
                        within the number range it must be infinite so return
                        false, else return true:
                        */
                        return (!isNaN(n = (+n))&&((n <= Number.MAX_VALU E)&&
                        (n >= Number.MIN_VALU E)));
                        };
                        }

                        Would you mind trying them on IE 4 and letting me no if there are any
                        problems with them.

                        Very few of the number formatting functions I have found are designed to
                        cope with the possibility that the number is in the range that would
                        normally be converted to a string in exponential format and I it
                        occurred to me that there might be some desire for methods that could
                        handle (or at least be aware of) that possibility.

                        To that end I was considering using the RegExp.exec method to split any
                        (non-NaN/Infinite) number up into its significant parts as one starting
                        point for more general formatting. The Regular expression that I have
                        been testing is:-

                        /^([+-])?(\d+)(\.(\d+) )?([eE]([+-]?)(\d+))?$/

                        With the array returned from RegExp.exec being used as: Index 1 is the
                        leading sign (if any), index 2 is the digits in front of the decimal
                        point in the mantissa, index 4 the digits that follow the decimal point,
                        index 6 is the sign of the exponent (if any) and index 7 the digits of
                        the exponent. Is there a regular expression better suited to the task of
                        splitting a string representation of a number up into its component
                        parts?

                        Richard.


                        Comment

                        • Dr John Stockton

                          #27
                          Re: Disable Drop-box Based On Users Selection

                          JRS: In article <buq4q9$1j8$1$8 302bc10@news.de mon.co.uk>, seen in
                          news:comp.lang. javascript, Richard Cornford
                          <Richard@litote s.demon.co.uk> posted at Fri, 23 Jan 2004 03:35:36 :-[color=blue]
                          >"Dr John Stockton" <spam@merlyn.de mon.co.uk> wrote in message
                          >news:RUU4ZPN1y +DAFwBN@merlyn. demon.co.uk...[/color]

                          [color=blue]
                          >While I was looking at the handling of numbers for formatting I noticed
                          >that IE 4 does not have isNaN and isFinite[/color]

                          My IE 4 does have them.

                          Small Flanagan says that isNaN is javascript 1.1 and isFinite is js 1.2;
                          and that both are ECMA-262. Also that IE4 & NS4 are js 1.2.

                          ISTM that the FAQ might list js versions for a few browsers, and that
                          answers in the FAQ might include js version needed, where known.

                          Scanning my site, I've used isNaN but not isFinite - ISTM that they do
                          not need emulating for FAQ purposes, because isNaN has appeared by NS3 &
                          IE4, isFinite by NS4 & IE3, and isFinite is not of much use. However,
                          one should consider other browsers of similar vintage.

                          [color=blue]
                          > but it struck me that NaN and
                          >Infinity would probably want special handling under some circumstances
                          >(maybe not often) and I wondered whether it would be worth emulating
                          >them for IE 4 (and maybe some others). These are the functions that I
                          >thought might be practical for the task:-[/color]

                          [color=blue]
                          >Would you mind trying them on IE 4 and letting me no if there are any
                          >problems with them.[/color]

                          Renamed versions seem to do what they should.

                          [color=blue]
                          >Very few of the number formatting functions I have found are designed to
                          >cope with the possibility that the number is in the range that would
                          >normally be converted to a string in exponential format and I it
                          >occurred to me that there might be some desire for methods that could
                          >handle (or at least be aware of) that possibility.[/color]

                          My routines in js-round.htm are designed to *always* show the right
                          value, even if the number is unreasonable for the routine - RSVP if any
                          of those alleged to be good do fail here.

                          Where a value, possibly the accumulated US budget in cents, cannot be
                          represented in the designated width, then ISTM that the programmer
                          should choose whether to break width or change format.

                          Where a value cannot be represented in the designated format, then ISTM
                          that the programmer should choose whether to change format.

                          Having a library routine change the format should be considered as a
                          sort of non-fatal error message.



                          [color=blue]
                          >To that end I was considering using the RegExp.exec method to split any
                          >(non-NaN/Infinite) number up into its significant parts as one starting
                          >point for more general formatting.[/color]

                          You cannot do that; you can only use a RegExp on a String representation
                          of a Number.

                          If a String represents a Number, then it can also be Hex or Octal, and
                          might have a decimal point not surrounded by decimal digits.
                          [color=blue]
                          >The Regular expression that I have
                          >been testing is:-
                          >
                          >/^([+-])?(\d+)(\.(\d+) )?([eE]([+-]?)(\d+))?$/
                          >
                          >With the array returned from RegExp.exec being used as: Index 1 is the
                          >leading sign (if any), index 2 is the digits in front of the decimal
                          >point in the mantissa, index 4 the digits that follow the decimal point,
                          >index 6 is the sign of the exponent (if any) and index 7 the digits of
                          >the exponent. Is there a regular expression better suited to the task of
                          >splitting a string representation of a number up into its component
                          >parts?[/color]

                          There *might* be value in capturing the previous and following
                          characters if present; and/or a space in the sign position.

                          I do not see the need for this.

                          If a Number is to be decomposed to that extent, it should be done by
                          arithmetic.

                          X=+0.00087
                          Neg = X<0
                          Pos = X>0
                          Nun = X==0 ; Mant=Expo=0
                          if (!Nun) {
                          A = Math.abs(X)
                          Expo = Math.floor(Math .log(A)*Math.LO G10E)
                          Mant = A*Math.pow(10, -Expo) }
                          Z = [Neg, Nun, Pos, Mant, Expo]

                          --
                          © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                          <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                          <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
                          <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

                          Comment

                          • Jim Ley

                            #28
                            Re: Disable Drop-box Based On Users Selection

                            On Fri, 23 Jan 2004 17:06:23 +0000, Dr John Stockton
                            <spam@merlyn.de mon.co.uk> wrote:
                            [color=blue]
                            >Small Flanagan says that isNaN is javascript 1.1 and isFinite is js 1.2;
                            >and that both are ECMA-262. Also that IE4 & NS4 are js 1.2.
                            >
                            >ISTM that the FAQ might list js versions for a few browsers, and that
                            >answers in the FAQ might include js version needed, where known.[/color]

                            This is something where I would disagree with Flanagan, JavaScript 1.2
                            only has relevance to NN4 JavaScript 1.5 has relevance for other
                            browsers, but IE4 is certainly not JavaScript 1.2 it's JScript 3.0 -
                            or more likely it's JScript 5.6 as I can't really imagine many people
                            letting an unpatched windows system out onto the web, even if they
                            insist on keeping IE4.

                            Jim.
                            --
                            comp.lang.javas cript FAQ - http://jibbering.com/faq/

                            Comment

                            • Dr John Stockton

                              #29
                              Re: Disable Drop-box Based On Users Selection

                              JRS: In article <4012759e.90064 235@news.cis.df n.de>, seen in
                              news:comp.lang. javascript, Jim Ley <jim@jibbering. com> posted at Sat, 24
                              Jan 2004 13:42:11 :-[color=blue]
                              >On Fri, 23 Jan 2004 17:06:23 +0000, Dr John Stockton
                              ><spam@merlyn.d emon.co.uk> wrote:
                              >[color=green]
                              >>Small Flanagan says that isNaN is javascript 1.1 and isFinite is js 1.2;
                              >>and that both are ECMA-262. Also that IE4 & NS4 are js 1.2.
                              >>
                              >>ISTM that the FAQ might list js versions for a few browsers, and that
                              >>answers in the FAQ might include js version needed, where known.[/color]
                              >
                              >This is something where I would disagree with Flanagan, JavaScript 1.2
                              >only has relevance to NN4 JavaScript 1.5 has relevance for other
                              >browsers, but IE4 is certainly not JavaScript 1.2 it's JScript 3.0 -
                              >or more likely it's JScript 5.6 as I can't really imagine many people
                              >letting an unpatched windows system out onto the web, even if they
                              >insist on keeping IE4.[/color]

                              All the more reason for putting it in the FAQ! You have later
                              information than Flanagan then did.

                              --
                              © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk DOS 3.3, 6.20; Win98. ©
                              Web <URL:http://www.merlyn.demo n.co.uk/> - FAQqish topics, acronyms & links.
                              PAS EXE TXT ZIP via <URL:http://www.merlyn.demo n.co.uk/programs/00index.htm>
                              My DOS <URL:http://www.merlyn.demo n.co.uk/batfiles.htm> - also batprogs.htm.

                              Comment

                              • Jim Ley

                                #30
                                Re: Disable Drop-box Based On Users Selection

                                On Sat, 24 Jan 2004 20:03:52 +0000, Dr John Stockton
                                <spam@merlyn.de mon.co.uk> wrote:
                                [color=blue]
                                >All the more reason for putting it in the FAQ! You have later
                                >information than Flanagan then did.[/color]

                                No Flanagan was simply wrong, and falling into the common confusion of
                                giving implementations which emulate JavaScript, JavaScript's version
                                number based on sort of how similar the implementations are, I don't
                                think that's constructive.

                                All we can really say now is ECMAScript Ed.1 is pretty safe, otherwise
                                it's a right mess IMO. What versions are supported where is not
                                frequently asked.

                                Jim.
                                --
                                comp.lang.javas cript FAQ - http://jibbering.com/faq/

                                Comment

                                Working...