Lesson 06
 
Lesson 6 - Reading

REQUIRED:

  • Read and do the practice work in Chapter 8
Lesson 6 - Notes and Practice Work

Working with Forms

Link Menu

<script>
function navigate(form)
{
selected=form.list.selectedIndex
if (form.list.options[selected].value == "")
{
alert("Please make a valid selection");
}
else
{
location.href=form.list.options[selected].value;
}
}
</script>

<form name="form1">
<select name="list" size="1" onChange="navigate(form1)">
<option selected>Select a Company</option>
<option>----------------</option>
<option value="http://www.microsoft.com">Microsoft</option>
<option value="http://www.dell.com">Dell</option>
<option value="http://www.gateway.com">Gateway</option>
<option value="http://www.apple.com">Apple</option>
<option value="http://www.oracle.com">Oracle</option>
</select>
</form>

Link Menu opens in a new window

<script>
function navigate(form)
{
selected=form.list.selectedIndex
if (form.list.options[selected].value == "")
{
alert("Please make a valid selection");
}
else
{
myurl = form.list.options[selected].value
window.open(myurl,'newwin','width=300,height=300')
}
}
</script>

<form name="form1">
<select name="list" size="1" onChange="navigate(form1)">
<option selected>Select a Company</option>
<option>----------------</option>
<option value="http://www.microsoft.com">Microsoft</option>
<option value="http://www.dell.com">Dell</option>
<option value="http://www.gateway.com">Gateway</option>
<option value="http://www.apple.com">Apple</option>
<option value="http://www.oracle.com">Oracle</option>
</select>
</form>

Verify Passwords

<html>

<script>
function validForm(passForm)
{
if (passForm.passwd1.value == "" )
{
alert("You must enter a password")
passForm.passwd1.focus()
return false
}

if (passForm.passwd1.value != passForm.passwd2.value)
{
alert("Passwords did not match")
passForm.passwd1.focus()
passForm.passwd1.select()
return false
}

return true

}
</script>

<body>

<form onSubmit="return validForm(this)" action="somepage.cgi">

Your name: <input type=text size=30>
<p>Password: <input type=password name=passwd1>
<p>Verify Password: <input type=password name=passwd2>
<p><input type=submit value=submit> <input type=reset>

</body>

</html>


Validate Zip Codes

<script>

function submitIt(Form)
{
if (!validZip(Form.zip.value)) {
alert(errmsg)
Form.zip.focus()
Form.zip.select()
return false
}
return true
}

function validZip(inZip)
{
if (isNum(inZip)) {
return true
}

return false
}

function isNum(passedVal)
{
if (passedVal == "") {
errmsg = 'Please Enter Zip Code'
return false
}

if (passedVal.length < 5) {
errmsg = 'Zip Code should be 5 digits'
return false
}

for (i=0; i<passedVal.length; i++) {
if ((passedVal.charAt(i) < "0") || (passedVal.charAt(i) > "9")) {
errmsg = 'Please use numbers only'
return false
}
}

return true
}

</script>

<form name="form1" onSubmit="return submitIt(this)" action="somepage.cgi">
Zip Code:
<input name="zip" type="text" size="5" maxlength="5">
<input type="submit" value="submit">

</form>

 

Lesson 6 - Assignment

  1. Create a single HTML file that contains the following:

    • select and go menu
    • dynamic change menu
    • email validation
    • zip code validation

  2. Save the file as CIS166AA06.HTM
  3. Upload the file and any images used to your CIS166aa folder on Gecko.

Send in Your Assignment to be Graded

After you have read these instructions, click on the link "Submit my assignment for grading" below. This will create a message for you to use to send in your assignment to the CIS166AA grader. It already will have the message address and the subject line filled in. DO NOT CHANGE THE ADDRESS OR THE SUBJECT LINE. Enter the following required information as the message text:

  • your full name
  • your palette account username
    • If you do not know your palette username, use your student ID card at a palette account lookup station in HTC1 or HTC2. If you are off campus, call the Student Help Desk at 623.845.HELP (4357) or send an email message to student-helpdesk@student.gc.maricopa.edu to request your palette username.
  • you email address
  • course section number
  • Include the full URL to lesson 6
    ( ie. http://gecko.gc.maricopa.edu/~palette_username/cis166aa/cis166aa06.htm )

Only by following this process can you be guaranteed that your assignment will get graded and the score recorded correctly.

Submit my assignment for grading

 


  Back to Top