View Full Version : My First JavaScript

09-28-2011, 10:21 PM
OK .. Solved ... there was a typing mistake in the code :)

Today is my first day to start learning JavaScript. When i try to run the following code (copy-paste from a book), the browser gives me an error. Can you please tell me what's wrong with the following code:

<SCRIPT LANGUAGE = "JavaScript">
function upperMe(){
document.converter.output.value = document.converter.input.value.toUpperCase()

<FORM NAME = "converter">
<INPUT TYPE = "text" NAME = "input" VALUE="sample" onChange="upperMe()">
<INPUT TYPE = "text" NAME = "output" VALUE="sdf">


09-28-2011, 10:29 PM
Also consider using document.forms instead of just document
It's clearer and more standard compliant.

document.forms.converter ... etc:)

Philip M
09-29-2011, 08:29 AM
<script language="javascript"> is long deprecated and obsolete. Use <script type = "text/javascript"> instead.

09-29-2011, 03:25 PM
I would also consider using onkeyup for this type of operation:
<INPUT TYPE = "text" NAME = "input" VALUE="sample" onkeyup="upperMe()">

onchange doesn't quite cut it for me, although I know it has its place...