Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask Programming Language Expert

Content: JavaScript tying into XHTML and CSS

Objectives: To obtain a solid understanding of client-side scripting and how it can be used to create dynamic content within a webpage.

Coverage: Client side programming with JavaScript, access Web page elements (DOM elements and CSS attributes), and change their content or values.

Note that your files must be validated correctly in order to receive full credit. XHTML 1.0 Strict is expected (unless otherwise specified by the exercises).

Exercise 1

The following set of short problems will focus on getting you familiar with JavaScript functions. All functions and testing should appear in a single XHTML 1.0 Strict page.

All your JavaScript functions must be declared in the document head section and each functions name must be as specified below. To demonstrate the functionality of each method, you must make function calls in the document body. Include a heading (h1… h6) that indicates which function is being tested before each function demonstration. The use of Global Variables is forbidden!

A. Function: addNumbers

Parameter(s): Array of numbers

Each element in the array must be added and the summation (answer) must be returned.

B. Function: getCurrentDate

Parameter(s): None

Retrieve the current date in the format similar to: Monday, May 10, 2010 and return it.

C. Function: arrayToString

Parameter(s): Array of words

All the elements of the array must be concatenated into a single string and returned.

D. Function: findMaxNumber

Parameter(s): None (Hint: Make use of the arguments array – page 167 in course book)

From the arguments array, find the number element that is the largest and return it.

E. Function: getDigits

Parameter(s): A String

Scan the string and find all the digits (0-9), concatenate them into a string in the order that they are found and return the string of numbers.

F. Function: reverseString

Parameter(s): A String

Reverse the entire string (character by character) and return the resulting string.


Exercise 2

Part 1

Given the following Regular Expressions, describe in detail the pattern accepted by each. Pay attention to all the characters being used. Your answers need not appear within an XHTML page.
A. /[a-z]*\s[0-9]*/
B. /\d+\.\d*/
C. /^\d{3}\-\d{4}$/
D. /^[A-Z]\d[A-Z]\-\d[A-Z]\d/
E. /(July|August)\s+\d{1,2}(\s|,)\d{4}/g

Part 2

Given the following descriptions, prepare a possible regular expression that expresses each of them.

Your answers need not appear within an XHTML page.

A. Matching a Name - First name must begin with a capital letter and be at least 2 characters long followed by either a ( , ) or a whitespace. The Last Name should begin with a capital letter and be at least 2 characters long but no greater than 20 characters long.

B. Matching an Email – First section should match word characters of any length except zero and must be followed by a @ symbol. The last section should match word characters of any length except zero and must not include an underscore ( _ ). A single period ( . ) must follow along with the word com at the end. No spacing is allowed within the pattern. The pattern need not match exactly (pattern can be a substring of a larger string).

Exercise 3

Given the following XHTML page:


   
        Exercise 3
   
   
       

User Information:


         

   


Create an embedded JavaScript function named getUserInfo that prompts the user with the following two problems after the XHTML page has loaded:

• What is your full name?
• How old are you?

The function should then build a string in the form of:

Hi, my name is FULL-NAME and I’m XX years old.

The string must then be inserted into the container div with id: content.

Note that your XHTML page must validate as 1.0 Strict – as such, make any needed additions to the XHTML code above.

Exercise 4

Copy and paste the following XHTML code into a new document:




Exercise 4


 

 

Order Books Online


 
  

   
    
     
     
     
    
    
     
     
     
    
    
     
     
     
    
    
     
     
     
    
   
BookQuantityPrice
Basic XHTML$19.99
Intro to PHP$86.00
Advanced JQuery$55.00

   


   
  

 
 




prepare JavaScript code that is executed during form submission to find out the cost of each book (based on quantity specified) and the overall total cost. The results should be displayed on the same page beneath the form submission button. Use any CSS at your discretion if desired.
All JavaScript code must be external. If any fields are left blank or do not contain a number, an alert box should display an appropriate error message upon form submission.
Note that your XHTML page must validate as 1.0 Strict – as such, make any needed additions or changes to the XHTML code above.

Exercise 5

Copy and paste the following XHTML code into a new document:




Exercise 6



 


 

Search a Course


 

  

    Enter the Course Name

   

   
   


  

 

 

  
 

  
Calculus I

  
Calculus II

  
Data Structures & Algorithms

  
Software Engineering I

  
Advanced C++

  
Computer Graphics

 

 





The above XHTML code validates as 1.0 Strict and must not be modified in anyway.
In an external JavaScript file prepare code that, upon form submission, scans the list of courses for a match (case should be insensitive). If a match is found, change the div’s background color to yellow. If no match is found, add the course name to the bottom of the course list (Hint: Read into DOM and Nodes). If the search field is left blank, return focus to the search field and display an alert box with an appropriate message. New searches must clear any yellow background before anything.

Exercise 6: Project

The last exercise of each assignment will be continuous from assignment to assignment and will have the goal of building an e-store website by the end of the course.

Date & Time

In the header area of your website, use JavaScript to display the current date and time. The time should automatically refresh every second.

Items on Sell

In the inside content area (see assignment 1) of your sites home page, you should create a small list of items that your store will be selling (your website can be a seller of whatever products you’d like). Each item should have a small thumbnail picture, an associated price, short description and a form button labeled “Add to Cart”. The button need not do anything when clicked at the moment.

Registration / Sign-up

In the side menu area (see assignment 1) add a link labeled “Register”. When clicked, the link should direct the user to a new page: register.html. This new page should include all the elements of your home page. In the inside content area, create a form with the following fields:

Text Fields: First name, Last name, Email Address, Phone Number
Password Fields: Password, Confirm Password

Use JavaScript to create some basic client-side validation. When the forms submit button is clicked, you should check to make sure that none of the fields are left blank. You must also check to see if both passwords match entirely. If validation fails, use an alert box to display an appropriate message that informs the user on what needs to be corrected. If validation is successful, do nothing for the time being.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91323

Have any Question? 


Related Questions in Programming Language

You must do this assignment correctly as described

You must do this assignment correctly as described below.  If you do not follow the directions or break the rules you will receive a 0 score. Simulation of checking tic-tac-toe board for wins by counting X and O in rows, ...

Purposethe purpose of this assignment is to practice using

Purpose: The purpose of this assignment is to practice using loops, selections, and other basic features of Java in order to solve a real-world problem. Program Description: The Jeddah Broker Company is one of the compan ...

Add a swift class file to the project that illustrates and

Add a SWIFT class file to the project that illustrates and contains the following: • The class name is 'Calculator' • Has public variables of the type float called numerator, denominator and total. • Has a method called ...

Questioncomplete tutorial 10 case problem 2 - ridgewood

Question: Complete Tutorial 10 Case Problem 2 - Ridgewood Herald Tribune found on pages 734-736 of your textbook. Complete the entire website assignment and upload your files to your 000WebHost account. After uploading t ...

Integrative programmingassignment- managing a user account

Integrative Programming Assignment- Managing a User Account List Objective: To manage a user list that can be modified and saved to a text file. Inputs: • Input text file consisting of pairs of usernames and passwords, s ...

Programming lab assignment set awhat to submitcomplete

Programming Lab Assignment (Set A) What to Submit Complete Problem Solving Steps 1 - 3 (check plan, data analysis, initial algorithm, and refinement algorithm) for the following programs. 1. (Name: lab1a-1.cpp) Write a p ...

Computerscienceprogram-writeallofthefollowingmainprogramcall

Computer Science Program- Write all of the following: main program: Call a function to open an input file. Call a function to read 3 integers in from the input file. Call a function that will find 3 normalized doubles, g ...

Assignmentyou will write a program that acts like a simple

Assignment You will write a program that acts like a simple calculator for binary numbers. You should read in a string of input that has the format: number operator number. Each of the numbers should be presented in two' ...

Csis program homeworkwrite a program where the user will

CSIS program homework Write a program where the user will enter a number between 1 and 50 representing a state. The program should display the full name of that state. Assume the states are in alphabetical order, that is ...

Consider the following three programswhere i k l are low

Consider the following three programs: where i, k, l are low variables and a, b, c, d, h, n are high variables. Assume db is a database with two columns (shown as array, where the index represents the row), lookup and is ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate