View Full Version : Form functions

07-21-2002, 07:42 PM
I'm new to Javascript and I'm having a terrible time understanding the whole process. I've had two classes and one assignment that I've spent hours trying to understand and complete and I'm still scratching my head. If anyone can help, I would appreciate it so much. The assignment reads:

When User Type1 is selected alert the text "a-" in the Username field, "b-" for type 2 and "c-" for Type 3

Change the alert to a custom function that will put the values "a-" or "b-", "c-" into the Username field.

Change the focus to the Username field after a user type has been selected.

This must be a very simple assignment and since I can't begin to understand how to do it...should I just give up the whole idea of learning it?

07-21-2002, 08:00 PM
First of all NEVER EVER GIVE UP!;)

I taught myself everything i know, it took alot of hard work and alot of scratching my head. Never give up perservier on through and you'll feel alot better on the other side. :D

Heres what i came up with, but Look at it study it see what i did and learn from it, it helps to see real examples.


<script language="javascript">

function changeUser(){



<select name="Type" onChange="changeUser()">
<option value="">Select A Type
<option value="a-">A Type
<option value="b-">B Type
<option value="c-">C Type
<input type="text" name="userType">


Hope this helps:D:D

P.S Remeber never give up!

07-21-2002, 08:43 PM
Thank you so much for the help. To be honest it is still all so foreign to me but hopefully one day it'll all come together.:)

07-21-2002, 09:20 PM
I'm new to Javascript and I'm having a terrible time understanding the whole process.

Here's my view of the big picture:

Hypertext Markup Langualge is what makes stuff show up on an internet browser. The boldface in the last sentence was done by using the bolface HTML tag. To keep it simple, let's just say HTML can't do much else other that how things look on the screen.

In order to give an internet page (an HTML page) some functionality - to allow a page to interact with a user- Javascript was created. The javascript computer language is integrated into HTML. Javascript was designed from the get-go to work with HTML, to compliment it, to allow a web page to do things HTML alone cannot. To use a javascript program we put it as part of the HTML tag we want it to work with.

Writing an entire Javascript program within an HTML tag would look like quite a mess. To make the javascript program easier to read, understand, write, and modify, we create javascript functions. A function is a chunk of javascript that you write that does something. Any given function usually has a single purpose in mind. An analogy would be the snooze button on your alarm clock. press the snooze button and the alarm is silenced for a pre-determined amount of time. Likewise when we call (press the button so to speak) a javascript function it does what it was programmed to do.

So,we write functions and from within HTML tags we call them.

Beyond the mechanics of doing the Javascript / HTML thing, and beyond the syntax of Javascript is learning how to program. Thats' something you can learn only by doing. A good instructor is invaluable here. In most classes the students are all so busy learning the basics of the language and just getting something to work that we tend to pick up that "how to program" very slowly. So hang in there. Grab hold of your teacher whenever you can and ask all the how, what, and why questions you can. Don't give up.

07-21-2002, 10:08 PM
You will one day figure it all out, and your very welcome, And just like RadarBob said Don't Give up :D:D:D:D:D