PROGRAM STEPS IN ENGLISH:



1.  start HTML
2.  start Head Section
3.  Create a title called "Scrolling Banner", end definition of title.
4.  Begin Script Language, using JavaScript.
5.  Define a string variable "BannerString" containing "This banner .."
6.  Create a variable named 'timer' set to 0;
7.  Define a function called "Scrollfunction()"
8.  Opening brace.
9.  Put the name of the string variable in 'boxtext' within 'box'
         within 'document'.
10.  Create a message by extracting a substring starting at the 1st
         position going to then end of the string and chaining that to
         the character at 0, the 1st character in the string.
11.  Set time-delay of 100 milliseconds for function "Scrollfunction()".
12. Close brace.
13. End Script section of program.
14. End Head Section.

15. Begin Body Section, when the html is loaded, call function
    "scrollfunction()"
16. Name the form "textform", and execute a script when form is submitted.
17. Define "textbox" with a  65 characters width.
18. End Body
19. End HTML


THIS EXERCISE HAS BEEN USED BY SEVERAL CLASSES WITH EXCELLENT
RESULTS.  'DEBUGGING' SKILLS ARE ESSENTIAL.  SHOW ME WHAT
YOU CAN DO, FOR YOUR SAKE.  BE AWARE THAT THERE ARE SOME
CHALLENGING  ERRORS IN THE CODE BELOW.

TO IMPROVE YOUR DEBUGGING SKILLS, THE FOLLOWING CODE HAS ERRORS
IN IT.  TRY TO REMOVE ERRORS BY A CAREFUL PROOF-READING, THEN
EXECUTE THE SCRIPT WITH A BROWSER (NETSCAPE OR IE).  WHEN ERRORS
OCCUR,  TYPE  javascript:   INTO THE LOCATION LINE, AND TROUBLE-SHOOT
THE CODE.  MAKE THE PROGRAM WORK.   JA. OUT.

IF LINES OF CONTINUE, DON'T HIT , JUST CONTINUE TO
TYPE.  DONT PUT A LINE-FEED/RETURN IN THE MIDDLE OF A LINE OF CODE.


Use the following JavaScript Statements to write the program:

(100 Points)



<CENTER> <INPUT TYPE>="text" NAME="texbox" SIZE="65" VALUE=""> </CENTER> <TITLE>Scrolling Banner</TITLE> <SCRIPT LANGEAGE="JavaScript"> { document.textform.textbox.value = ScrollString; ScrollString= ScrollString.substring(1,ScrollString.length) + ScrollString.CharAt(0) function Scrollon() var ScrollString="This banner was created by Mauricio Chacon,<BR> with the understanding that he will help others put it on their web pages. <BR> Go Mauricio! "; timer = setTimeout("Scrollon()",100) ; } <HTML> <HEAD> <BODY BGCOLOR=yellow onLoad = Scrollon()> var timer = 0; <FORM NAME = "textform" onSubmit = "0"> </SCRIPT> </HEAD> </BODY> </HTML>


Activities:



Understanding Time-Delay:

    Drop 100 to 1.  read fast!



Understanding Substring:

    Can you extract the  substring  "Mauricio" and display it?

    The substring's arguments are  substring(start, end)



    What is the 1st position -- 0 or 1?



Understanding charAt()

     What does it do?



Note the hierarchial method --   document.textform.textbox.value = 



says that within the document is a textform within it is textbox whose

value is ....



THERE IS A TEXTBOX WITHIN A TEXTFORM WITHIN A DOCUMENT!

add the alert statement to trace the flow.