beginner question... onChange?

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

    beginner question... onChange?

    This code is very simple, but it doesn't do anything.. can someone point
    out what I'm doing wrong please..
    When user enters text into t11, it should be copied to t12.

    <HTML>
    <HEAD>
    <title>onChan ge Test</title>
    </HEAD>
    <BODY>
    <script language="JavaS cript">
    function recalc()
    {
    document.frm.t1 2.value = document.frm.t1 1.value;
    }
    </script>
    <FORM name="frm" method="post" action="post">
    Source <input name="t11" type="text" onChange="recal c(); return
    true;" />
    <br>
    Target <input name="t12" type="text" />
    </FORM>
    </BODY>
    </HTML>

    --
    Thanks
    Adrian



  • Michael Winter

    #2
    Re: beginner question... onChange?

    On Fri, 10 Sep 2004 08:53:20 GMT, Adrian Parker <apparker@nospa m.com>
    wrote:
    [color=blue]
    > This code is very simple, but it doesn't do anything.. can someone
    > point out what I'm doing wrong please.
    > When user enters text into t11, it should be copied to t12.[/color]

    As far as I can see, it works exactly as it should. The change event
    doesn't fire until the control loses focus, and will only fire if the
    value changed between the control getting focus and losing it again. Type
    something then press Tab or click somewhere with the mouse. The value will
    be copied.

    By the way, you can remove the return statement. It doesn't do anything.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Adrian Parker

      #3
      Re: beginner question... onChange?

      Ack!

      Ok, found problem.. it's a good idea to not use a javascript function name
      as your function name.. if I change recalc() to txtcalc() all is well.

      -Adrian


      Comment

      • Grant Wagner

        #4
        Re: beginner question... onChange?

        Adrian Parker wrote:
        [color=blue]
        > Ack!
        >
        > Ok, found problem.. it's a good idea to not use a javascript function name
        > as your function name.. if I change recalc() to txtcalc() all is well.
        >
        > -Adrian[/color]

        "recalc" is a javascript function name? What implementation, what user agent?

        It's not a reserved word in JavaScript 1.5:

        <url:

        />

        and it is "undefined" in IE6SP1, Netscape 4.78, Opera 6.05 and Opera 7.54.

        --
        Grant Wagner <gwagner@agrico reunited.com>
        comp.lang.javas cript FAQ - http://jibbering.com/faq

        Comment

        • Richard Cornford

          #5
          Re: beginner question... onChange?

          Grant Wagner wrote:[color=blue]
          > Adrian Parker wrote:[color=green]
          >> Ok, found problem.. it's a good idea to not use a javascript
          >> function name as your function name.. if I change recalc() to
          >> txtcalc() all is well.[/color]
          >
          > "recalc" is a javascript function name? What implementation,
          > what user agent?[/color]

          It is a method of the - document - object in IE 5.5+. It gets picked up
          from event handling attribute code because IE's custom scope chains on
          internally generated event handling functions include the - document -
          object.

          Of course that means that it is not a javascript/ECMAScript function at
          all. (And I cannot remember what it is that the method does, I don't
          remember it seeming that useful when I did look it up at MSDN.)

          Richard.


          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: beginner question... onChange?

            Richard Cornford wrote:
            [color=blue]
            > Grant Wagner wrote:[color=green]
            >> "recalc" is a javascript function name? What implementation,
            >> what user agent?[/color]
            >
            > It is a method of the - document - object in IE 5.5+. It gets picked up
            > from event handling attribute code because IE's custom scope chains on
            > internally generated event handling functions include the - document -
            > object.
            >
            > Of course that means that it is not a javascript/ECMAScript function at
            > all. (And I cannot remember what it is that the method does, I don't
            > remember it seeming that useful when I did look it up at MSDN.)[/color]

            | recalc Method
            |
            | Recalculates all dynamic properties in the current document.

            <http://msdn.microsoft. com/workshop/author/dhtml/reference/methods/recalc.asp>


            PointedEars
            --
            It doesn't work. I don't know why.

            Comment

            Working...