run time check

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

    #1

    run time check

    Hi

    I have this problem.

    I have a function like this.

    function evaluate(tekst)
    {
    var ctrl;

    ctrl = "control" + 5;
    if(tekst=='good ')

    {
    document.formna me.ctrl .checked = true;
    }


    }

    In the form there is a checkbox control named control5

    but this doesn't work. I have the error ctrl not found in form.
    I understand the reason but which is the solution?


    Thanks

    Alain Dhaene


  • Evertjan.

    #2
    Re: run time check

    Alain Dhaene wrote on 06 jan 2004 in comp.lang.javas cript:
    [color=blue]
    > ctrl = "control" + 5;
    > if(tekst=='good ')
    >
    > {
    > document.formna me.ctrl .checked = true;
    > }
    >[/color]

    document.formna me[ctrl].checked

    ?

    =============== =

    more consize, also unchecks:

    document.formna me["control"+5].checked=(tekst =='good')

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • McKirahan

      #3
      Re: run time check

      "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
      news:Xns9468835 488D5Aeejj99@19 4.109.133.29...[color=blue]
      > Alain Dhaene wrote on 06 jan 2004 in comp.lang.javas cript:
      >[color=green]
      > > ctrl = "control" + 5;
      > > if(tekst=='good ')
      > >
      > > {
      > > document.formna me.ctrl .checked = true;
      > > }
      > >[/color]
      >
      > document.formna me[ctrl].checked
      >
      > ?
      >
      > =============== =
      >
      > more consize, also unchecks:
      >
      > document.formna me["control"+5].checked=(tekst =='good')
      >
      > --
      > Evertjan.
      > The Netherlands.
      > (Please change the x'es to dots in my emailaddress)[/color]


      Perhaps?

      <html>
      <head>
      <title>control5 .htm</title>
      <script language="javas cript" type="text/javascript">
      <!--
      function evaluate(tekst) {
      var form = document.forms[0];
      var ctrl;
      ctrl = eval("form.cont rol" + 5);
      if (tekst=='good') {
      ctrl.checked = true;
      }
      }
      // -->
      </script>
      </head>
      <body>
      <form>
      <input type="checkbox" name="control5" >
      <input type="button" value="check" onclick="evalua te('good')">
      </form>
      </body>
      </html>


      Comment

      • Evertjan.

        #4
        Re: run time check

        McKirahan wrote on 06 jan 2004 in comp.lang.javas cript:[color=blue]
        > var form = document.forms[0];
        > var ctrl;
        > ctrl = eval("form.cont rol" + 5);[/color]

        eval is evil!

        document.forms[0]["control"+5].checked=(tekst =='good')


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • McKirahan

          #5
          Re: run time check

          "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
          news:Xns9468AA5 AD6D47eejj99@19 4.109.133.29...[color=blue]
          > McKirahan wrote on 06 jan 2004 in comp.lang.javas cript:[color=green]
          > > var form = document.forms[0];
          > > var ctrl;
          > > ctrl = eval("form.cont rol" + 5);[/color]
          >
          > eval is evil![/color]


          I knew I was going to get some flak for suggesting its use.

          Can you give me (or point me to) the reasons?

          Thanks.


          Comment

          • HikksNotAtHome

            #6
            Re: run time check

            In article <7iBKb.758459$T r4.2155828@attb i_s03>, "McKirahan"
            <News@McKirahan .com> writes:
            [color=blue][color=green]
            >> eval is evil![/color]
            >
            >
            >I knew I was going to get some flak for suggesting its use.
            >
            >Can you give me (or point me to) the reasons?[/color]





            Major Reason: Its inherently slower (I know of one instance where eval actually
            performs as well/better than other methods).
            --
            Randy

            Comment

            • Evertjan.

              #7
              Re: run time check

              McKirahan wrote on 06 jan 2004 in comp.lang.javas cript:
              [color=blue]
              > "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
              > news:Xns9468AA5 AD6D47eejj99@19 4.109.133.29...[color=green]
              >> McKirahan wrote on 06 jan 2004 in comp.lang.javas cript:[color=darkred]
              >> > var form = document.forms[0];
              >> > var ctrl;
              >> > ctrl = eval("form.cont rol" + 5);[/color]
              >>
              >> eval is evil![/color]
              >
              >
              > I knew I was going to get some flak for suggesting its use.
              >
              > Can you give me (or point me to) the reasons?[/color]

              <http://groups.google.c om/groups?num=100& q=eval+evil+jav ascript>

              <http://www.google.com/search?as_q=eva l+evil+javascri pt&num=100>



              --
              Evertjan.
              The Netherlands.
              (Please change the x'es to dots in my emailaddress)

              Comment

              Working...