JavaScript Tutorial - 7

Just for fun! ... from an idea by John Rogers
your name please:
grade this tutorial from 1 to 10:

Ok - quite a few new techniques needed here - let's take them one at a time.
Firstly, make sure you can still do
Task 13: Produce a page with a button that says "Hello!" when you press it. Check.

type your name please

Think about this example carefully ... there are several input boxes on this page ... how do we tell JavaScript we want the value from this particular one?
We do it by giving it a name, like this:

<input type=text name=box> Of course, you can give it any name you want.
Not quite that simple however ... there may be another one named "box" on our page.
We also have to give the form a name in the same way.
Suppose I call the form, task19, then we refer to the typed value thus: document.task19.box.value Task 19: Same as my example EXCEPT that I only require an echo of the name. Check.

Task 20: Repeat Task 19 using your own function called say_hello. Check.

To "add" "Hello" to the front of your message, you simply use a plus sign +

Task 21: Repeat Task 20 so it now really says "Hello". Check.

HOME Table of Contents Previous Next