[Javascript] Why is script line needed to change values
Nick Fitzsimons
nick at nickfitz.co.uk
Mon May 21 16:04:17 CDT 2007
On 21 May 2007, at 21:45:10, twlewis at SoftHome.net wrote:
> I apologize, because this is a little off-topic from javascript. I
> had
> completed my javascript, which loads data to a textarea. It would not
> load the textarea. I have a VBScript version that worked. After much
> careful elimination of code on the VBScript version, I found that
> the line
> that was making the onclick work was the script statement. I
> created a
> chopped down version to test and play with. In the script below, if I
> remove the line
> <script Language="VBScript" src="none"></script>,
> the onclick no longer works. I can paste it back in, and the button
> changes as it is supposed to. Can someone please explain this to me?
> Thank you for your patience and explanation.
> Tim
>
>
> <html>
> <head>
> <script Language="VBScript" src="none"></script>
>
> </head><body>
> <form id=myform>
> <input type="button" value="Click me!" id=Button1 name="button">
>
> <input type="button" value="Change button 1 to monkey"
> onclick="Button1.Value='monkey'">
>
> </form>
> </body>
> </html>
The presence of a <script> tag with "language="VBScript" will cause
Internet Explorer to assume that the onclick="" handler is in
VBScript. VBScript is case-insensitive, unlike JavaScript, and the
"value" property starts with a lower-case "v".
So if you remove the <script> tag and use
Button1.value = 'monkey'
(instead of Value) for the onclick attribute then it will work in all
browsers that support JS, whereas at the moment it will only work in IE.
HTH,
Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/
More information about the Javascript
mailing list