Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Create a snippet of raw JavaScript code (i.e., so no JQuery ) that uses the D

ID: 3705104 • Letter: 1

Question

1.       Create a snippet of raw JavaScript code (i.e., so no JQuery) that uses the DOM to create an HTML form. You will have to attach the form to an existing ‘div’ on the page. The form requires four inputs:

a.       A user name input – required, and allows only letter and number values with a pattern of 2 characters minimum and 14 characters maximum

b.       An age input that is required and only accepts numbers between 18 and 99

c.       An email input that is required and has to be in email format

d.       A submit input with the label ‘submit’

2.       Given an existing JQuery ‘click’ function (e.g., see ‘jquery-ajax-get-list.html’ from the week 10 examples folder), use JavaScript to retrieve the data from an AJAX call to PHP and display a table within the page (note: you can use JQuery for this). The structure of the data sent from PHP is in JSON format consists of a JSON object that contains an array of records (e.g., customers). Put each attribute (name, id, age, email) of the customer into a column in the HTML table. The data sent from PHP looks something like this:
{“status”: “success”, “customers”: [{“name”: “arron”, “id”: “42”, “age”: “29”, “email”:”me@arronferguson.com”}, …]}

3.       Using SQL, create a table called user that has a primary key called ‘ID’, a first name (up to 30 characters), last name (up to 30 characters), and an email address (up to 30 characters). Utilize MySQL’s auto increment feature for the primary key. Also add one record to the user table (via SQL) and then list all records (again, via SQL).

4.       Assuming the table listed in question three has records in it, use PHP to cycle through the list of records (like your lab eight), and output with the PHP code an HTML table (again, like lab eight). Note: the PDO code will be filled in for you

5.       Create a PHP function called ‘total’ that accepts two values and checks both values to see if they are not null and that they are both numbers. If they are both numbers, return their sum. Otherwise, return null.

Explanation / Answer

3.CREATE TABLE user(

Id INT NOT NULL AUTO_INCREMENT,

First_Name VARCHAR(30) NOT NULL,

Last_Name VARCHAR(30) NOT NULL,

Email_Address VARCHAR(30) NOT NULL,

PRIMARY KEY(Id)

);

Insert into user values('pooja','SH','pooja@abc.com');

select * from user;

Id First_Name Last_Name Email_Address

1 pooja SH pooja@abc.com