Dr John Stockton wrote:
> JRS: In article < >, seen
> in news:comp.lang.javascript, Jim <> posted at
> Thu, 3 Jun 2004 13:27:04 :
>
>
>>function enableField()
>>{
>>if (chxrequest.checked)= true
>>{
>>document.frmcallreport.txtrequest.disabled= false;
>>}
>>if (chxrequest.checked)= false
>>{
>>document.frmcallreport.txtrequest.disabled= true;
>>
>>}
>>
>> }
>
>
>
> (a) In javascript, = is assignment, not comparison
That depends, directly on the browser and how the script tag is
constructed. In Netscape 4.xx with language="javascript1.2", then the =
does indeed do a comparison.
> (b) It is almost never desirable to compare with true or false
> (c) For the body of the function, this is simpler :
> document.frmcallreport.txtrequest.disabled = ! chxrequest.checked
But this is better:
document.frmcallreport.txtrequest.disabled =
!document.frmcallreport.chxrequest.checked
the chxrequest.checked shortcut is an IE-ism.
> (d) The function would be more general / more expressive with chxrequest
> as a parameter
> (e) ISTM that you need a better instructor, or a more competently-
> written book; for the latter, see the newsgroup FAQ.
No comment.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq/