This project is intended to give students experience in composing a small web page involving the manipulation of objects using JavaScript. Although many different techniques exist for coding and executing
scripts, this project will require that the script be coded as a [function] in the head section of an
XHTML file. This program will rely primarily on the use of pop-up prompt (dialog) boxes for input
and will produce HTML output using JavaScript document.write methods. See the [W3Schools tutorial page about JavaScript Popup Boxes].
As with prior projects, this project will be written using a plain text editor to help students
develop a fundamental understanding of XHTML and JavaScript syntax.
The script shall request and store a customer's first name, last name, and social security number (SSN). Both names may be entered in any case letters. The SSN must be entered using only digits (without hyphens). Generate an account name by concatenating the last four digits of the SSN to the end of the first four characters of the customer's last name in lowercase. Generate a password by concatenating the first four characters (in lowercase) of the customer's first name to the end of the first five digits of the SSN. For example, a customer named "Janet Wilson" with a SSN of "123456789" would be assigned an account name of "wils6789" and a password of "12345jane". For customers with names shorter than four characters, use just the letters provided (understanding that the resulting account name or password may be shorter than standard). Finally, display those results in the browser window in a manner similar to that shown in the OUTPUT area of the Sample Output below.
Initially, your browser window should display:
This web page can generate a customer account name and password, constructed from data related to the customer's identity. A script on the page will request and store a customer's first name, last name, and social security number (SSN). Both names may be entered in any case letters. The SSN must be entered using only digits (without hyphens). The script will generate an account name by concatenating the last four digits of the SSN to the end of the first four characters of the customer's last name in lowercase. Generate a password by concatenating the first four characters (in lowercase) of the customer's first name to the end of the first five digits of the SSN. For example, a customer named "Janet Wilson" with a SSN of "123456789" would be assigned an account name of "wils6789" and a password of "12345jane". For customers with names shorter than four characters, the script will use just the letters provided. The results will appear in the browser window after the customer data has been entered. Click on the button below to start the process.
To produce the button above, include the source code:
<form action=""> <input type="button" value="Create account credentials" onclick="createUserid()"/> </form>
The onclick event handler will run a script that you write in the head section
named createUserid() that will generate the account credentials.
After your script has acquired the following data with prompt dialog boxes
your browser window's contents should be altered to display:
First Name: Janet
Last Name: Wilson
Social Security #: 123456789
Username: wils6789
Password: 12345jane
Note that the header and horizontal rule do not change; but all content below that does.
http://www.gibsonr.com/classes/internet/examples/javascript/jsex_func_by_event.htmIn order to execute the JavaScript content of that document, you might have to reconfigure your browser's security settings as described on the page about Browser Security Configuration for Scripts.
<!-- Comment here --><?xml version='1.0' encoding='utf-8'?> <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
// style of JavaScript comment notation at the front of those statements to
"comment out" the alert statements prior to submitting your code. For example: //alert ("Input section of script reached.");<!-- and --> in XHTML
and /* and */ in JavaScript) to mask any code that is causing trouble, move on to a
different element, and come back to solve the problem later. Some frustration can be a valuable motivator
to reinforce lessons. But too much can inhibit learning. Schedule your time to allow some breaks between
working sessions.Login to the and use the Project 5 drop box under the Lessons tab to attach your "project5.htm" file.