Thomas 'PointedEars' Lahn said the following on 12/13/2005 1:55 PM:[color=blue]
> Tony wrote:
>
>[color=green]
>>@sh wrote:
>>[color=darkred]
>>>IN THE HEAD
>>>function CopyTextBoxes(TextBox1,TextBox2) {
>>> if(TextBox2.value = '') { **** here is your
>>> problem
>>> TextBox2.value = TextBox1.value}
>>>}[/color]
>>
>>Your if statement is SETTING TextBox2.value to '',[/color]
>
>
> Ahh, I missed that.
>
>[color=green]
>>which returns true,[/color]
>
>
> It does not return anything. You describe JavaScript 1.2-specific
> behavior as implemented in Netscape Navigator 4.0 to 4.05 (June 1997)
> and in other browsers if <script ... language="JavaScript1.2"> is used.
> There the AssignmentExpression _evaluates to_ `true' if successful,
> `false' otherwise.
>
> However, version/implementation-unspecific behavior is that TextBox2.value
> is indeed assigned a value; that value is the empty string which
> type-converts to `false', ...[/color]
You are not testing the .value of that input. The test, as above, is
testing to see if you can set it's value to '', which you can, which
evaluates to true.
var myVar;
if (myVar = '3'){
alert('This alert will always fire in a decent UA')
}
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/