beginner question... onChange?

A

Adrian Parker

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>onChange Test</title>
</HEAD>
<BODY>
<script language="JavaScript">
function recalc()
{
document.frm.t12.value = document.frm.t11.value;
}
</script>
<FORM name="frm" method="post" action="post">
Source <input name="t11" type="text" onChange="recalc(); return
true;" />
<br>
Target <input name="t12" type="text" />
</FORM>
</BODY>
</HTML>
 
M

Michael Winter

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.

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
 
A

Adrian Parker

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
 
G

Grant Wagner

R

Richard Cornford

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

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.
 
T

Thomas 'PointedEars' Lahn

Richard said:
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.)

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

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


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top