Re: how to Enable/Disable textbox dynamically



Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
<snip>
<select name="Loan_Amount_Operator"
onchange="javascript:enableLoanFields(this.form, this.value)">
`javascript:' here ranges from being redundant to being a syntax
error.

No it is not a syntax error as a label may appear associated
with any statement in javascript. [...]

Labels (LabelledStatement production) were not introduced
before ECMAScript Edition 3.

But they were implemented long before they were formally specified, so worrying about them being syntax errors may be worrying about environments that have long since gone out of use.

Omit it, and use the following declaration for the default
scripting language once within the `head' element:

<meta http-equiv="Content-Script-Type" content="text/javascript">
<snip>

No evidence exists that any browsers pay any attention to either
this META element or would pay any attention to the HTTP header
that it is supposed to be the 'http-equiv' of.

Not yet, I daresay.

That would make it harmless but redundant (formal correctness only
for the sake of formal correctness).

It is not incorrect to omit it, but given the recommendation in the
HTML 4.01 Specification, it would be unwise.

I think that to recommend doing things for the sake of formal correctness alone without saying as much is a mistake, it undermines the credibility of your recommending doing things that are formally correct where doing them or not may make a difference, such your recommendation to correct the structural invalidity in the mark-up by not placing the SCRIPT elements as the first children of the HTML element (or, as the mark-up would be interpreted, not having two opening HEAD tags (the first implied and the second actual)).

However, in a JSP you have direct access to a facility for setting
the HTTP headers for the generated page, and so you can (and
should) provide the actual HTTP header rather than (any)
'http-equiv' META elements.

Agreed. However, there is no Content-Script-Type header
defined in HTTP/1.0 or HTTP/1.1.

Which is the reason that the HTML 4.01 proposal for defaulting script languages is commonly perceived as a joke. On the other hand, HTTP is tolerant of 'unrecognised' headers.

It is recommended in HTML 4.01 to use that `meta'
element when using event handler attributes anyway.

The perception of scripting by the authors of HTML 4.01 was distinctly confused, to the point of being near unworkable. Apart from demonstrating the use of a non-existing MIME type for javascript, they specified a TYPE attribute for SCRIPT elements but forgot to mirror it in NOSCRIPT element attributes (making a nonsense of their own example of the use of NOSCRIPT by putting it next to a SCRIPT element of type="text/tcl" so that in real world browsers exposed to the code not only would the script not be executed (due to them not supporting text/tcl) but the NOSCRIPT content would not be shown either because javascript would be enabled on the browser). If these people make a joke out defaulting the interpretation of attribute code then the joke may be on us if we play along.

Richard.

.



Relevant Pages