Option group help for a beginner?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • What-a-Tool

    #16
    Re: Option group help for a beginner?


    "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
    news:cam8at$4rb $1$8300dec7@new s.demon.co.uk.. .
    [color=blue]
    > As you are learning you might like to know that it is never necessary to
    > compare a boolean value with a boolean value to get a boolean result, as
    > you are doing in this case.[/color]
    [color=blue]
    > Also, the - eval - function is almost never needed in javascript, and so
    > almost never used by javascript authors who know what they are doing.[/color]
    [color=blue]
    > eval("document. frmsubmitF.call func.checked")
    >
    > - is *exactly* the same, in terms of what it does, as:-
    >
    > document.frmsub mitF.callfunc.c hecked
    >
    > - except that the - eval - call is two to twenty times slower[/color]
    [color=blue]
    > So your - if - statement can be re-written as:-
    >
    > if(document.frm submitF.callfun c.checked){
    >
    > - and do exactly the same as it does now, but be faster, clearer and
    > more reliable.
    >[/color]

    Thanks for the code evaluation.
    My background is in VB.Net - the double check for a boolean makes sense - I
    wouldn't do it in VB, but don't see these things quite so clearly in
    Jscript. Thanks for the pointer and the tip on eval

    [color=blue]
    >
    > Incidentally, asking people to write you specific explanations because
    > you "don't have time to read every word of" a pre-written explanation
    > that you have been referred to is not going to go down well on Usenet.
    > These web page explanations get written to save us time by not having to
    > re-write the same explanation of the same things over and over again.
    >
    > Richard.[/color]

    I did skim thru the faq the first time you directed me there. As you can
    see, I didn't know which paragraph you you were
    refering to. My oversite. Usually, when I resort to a newsgroup post, I am
    in the middle of a project, stuck, frustrated, and hoping for a solution as
    quick as possible. (and usually get it)
    You directed me there a second time - I skimmed thru it again and still
    didn't see. Other things on my mind I guess. Again - my mistake.


    Comment

    • Dr John Stockton

      #17
      Re: Option group help for a beginner?

      JRS: In article <calgkk$agc$1$8 300dec7@news.de mon.co.uk>, seen in
      news:comp.lang. javascript, Richard Cornford
      <Richard@litote s.demon.co.uk> posted at Tue, 15 Jun 2004 01:41:41 :[color=blue]
      >Dr John Stockton wrote:[color=green]
      >> Richard Cornford wrote:[/color]
      ><snip>[color=green][color=darkred]
      >>>Did you read section 2.3 of the newsgroup FAQ and the pages it
      >>>links to? If so why have you disregarded what they say?
      >>>
      >>><URL: http://www.jibbering.com/faq/#FAQ2_3 >[/color]
      >>
      >> ISTM that Sec 2.3 does need to have its paragraphs numbered (perhaps
      >> with <H4>); and that it might be improved by a total re-write.[/color]
      >
      >There are quite a lot of similar suggestions for improvements to the
      >general presentation (in text and HTML versions) but they will take a
      >serious revision of the XML format used as the current version will not
      >accommodate them.[/color]

      Surely the paragraphs can be numbered by inserting <number stop space>
      in the source immediately before the first word? There's only about ten
      of them. Or <parenthesis letter parenthesis space> might be better.

      The tools used must not be allowed to get in the way of improving the
      content.

      --
      © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
      <URL:http://jibbering.com/faq/> JL / RC : 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

      • Dr John Stockton

        #18
        Re: Option group help for a beginner?

        JRS: In article <qMszc.3008$0z6 .2534@fed1read0 7>, seen in
        news:comp.lang. javascript, What-a-Tool <Die!FrigginSpa mmersDieDie!@IH ate
        Spam.Net> posted at Mon, 14 Jun 2004 22:01:59 :
        [color=blue]
        >Following is some of my code:[/color]
        [color=blue]
        >if (eval("document .frmsubmitF.cal lfunc.checked") == true)[/color]
        [color=blue]
        >My Problem has been pointed out to me :[/color]

        But not all of the flaws.

        Function eval is needed only as described in FAQ 4.40, and should not be
        used otherwise (unless a new class of need exists, in which case please
        explain here).

        Testing for equality with true is unnecessary, at least almost always :

        if (document.frmsu bmitF.callfunc. checked) // should work

        --
        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
        <URL:http://jibbering.com/faq/> JL / RC : 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

        • What-a-Tool

          #19
          Re: Option group help for a beginner?

          >[color=blue]
          > Function eval is needed only as described in FAQ 4.40, and should not be
          > used otherwise (unless a new class of need exists, in which case please
          > explain here).
          >
          > Testing for equality with true is unnecessary, at least almost always :
          >
          > if (document.frmsu bmitF.callfunc. checked) // should work
          >
          > --
          > © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE[/color]
          4 ©[color=blue]
          > <URL:http://jibbering.com/faq/> JL / RC : FAQ for[/color]
          news:comp.lang. javascript[color=blue]
          > <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates,[/color]
          sources.[color=blue]
          > <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items,[/color]
          links.


          Follows is the code I was using:

          <form name="frmsubmit inches" id="frmsubmitin ches" onsubmit="retur n
          wheretogo();" action="noscrip t.htm" method="post">


          function wheretogo()
          {
          var intinches = document.frmsub mitinches.txtIn ches.value

          if (intinches.leng th > 0 && IsNumeric(intin ches))
          {
          if(eval("docume nt.frmsubmitinc hes.callfunc.ch ecked")==true)
          {
          alert("Calling ASP Function");
          document.frmsub mitinches.actio n = "calc_feetfunct ion.asp";
          }
          if(eval("docume nt.frmsubmitinc hes.callsub.che cked")==true)
          {
          alert("Calling ASP Sub-Routine");
          document.frmsub mitinches.actio n = "calc_feetsubro utine.asp";
          }
          if(eval("docume nt.frmsubmitinc hes.callclass.c hecked")==true)
          {
          alert("Calling ASP Class");
          document.frmsub mitinches.actio n = "calc_feetclass .asp";
          }
          }
          else
          {
          alert ("You must enter a valid numeric value in the inches text box!")
          return false;
          }


          Changed this to :

          if("document.fr msubmitinches.c allfunc.checked ")
          {
          alert("Calling ASP Function");
          document.frmsub mitinches.actio n = "calc_feetfunct ion.asp";
          }

          For some reason, this didn't work. The code traveled thru each of my "If"
          statements, calling each of my 3 alert boxes, before finally acting on the
          third < document.frmsub mitinches.actio n = "calc_feetclass .asp"; > to
          call my ASP page.
          For now, I'm still using the eval function, till I can figure out why it is
          acting like this.


          Comment

          • Richard Cornford

            #20
            Re: Option group help for a beginner?

            What-a-Tool wrote:
            <snip>[color=blue]
            > Changed this to :
            >
            > if("document.fr msubmitinches.c allfunc.checked ")[/color]
            ^ ^
            If you put quotes around the property accessor it becomes a string
            literal. Non-empty string literals are always true (internally
            type-converted to boolean true for the evaluation of the - if -
            expression).

            <snip>[color=blue]
            > For some reason, this didn't work. The code traveled thru each of my
            > "If" statements, calling each of my 3 alert boxes, before finally
            > acting on the third < document.frmsub mitinches.actio n =
            > "calc_feetclass .asp"; > to call my ASP page.
            > For now, I'm still using the eval function, till I can figure out why
            > it is acting like this.[/color]

            Usenet constantly serves to amaze me that there appear to be so many
            people working in the role of programmers (in one sense or another) who
            cannot apply logic to problem solving. What you have done in your last
            post is present a complete function that was doing what you wanted it to
            do (badly, but at least it was functional) and then posted only an
            extract from the code that doesn't work. While you might have got lucky
            in this case, isn't it obvious that if you don't know what is wrong with
            some code you cannot decide which extract might contain the problem. And
            if we cannot *see* the code that doesn't work we cannot tell why it
            might not be working.

            You are really going to have to get around to reading the resources that
            I referred you to soon or you are going to end up wasting a lot of your
            own time (which is up to you) and a lot of other people's time (which
            would be unwelcome).

            Richard.


            Comment

            Working...