0% found this document useful (0 votes)
4 views5 pages

Final Key

The document is a final exam key for CSE 190 M from Spring 2007, covering topics such as HTML/CSS, JavaScript/DOM, Ajax/XML, PHP, and SQL. It includes code snippets and examples relevant to each topic, demonstrating various programming concepts and techniques. The content is structured in a way that reflects the exam's focus on practical coding skills and problem-solving.

Uploaded by

radji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Final Key

The document is a final exam key for CSE 190 M from Spring 2007, covering topics such as HTML/CSS, JavaScript/DOM, Ajax/XML, PHP, and SQL. It includes code snippets and examples relevant to each topic, demonstrating various programming concepts and techniques. The content is structured in a way that reflects the exam's focus on practical coding skills and problem-solving.

Uploaded by

radji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CSE 190 M, Spring 2007

Final Exam Key


1. HTML/CSS

Scene
#7
Elizabeth: Captain Barbosa, I am here Barbossa: There are a lot of long words in
to negotiate the cessation of hostilities
against Port Royal.

there, Miss.
What is it that you want?
Elizabeth: I want you to leave and never come back.
Barbossa: I'm disinclined to acquiesce to your request. Means "no."

1 of 5
2. Javascript/DOM
window.onload = loadq2;

function loadq2() {
var del = document.getElementById("del");
del.onclick = divideAll;
}

function divideAll() {
var divisor = document.getElementById("divisor").value;
var div = document.getElementById("q2buttons");
var buttons = div.getElementsByTagName("button");
for (var i = 0; i < buttons.length; i++) {
if (buttons[i].innerHTML % divisor == 0) {
div.removeChild(buttons[i]);
i--;
}
}
}
or:
window.onload = loadq2;

function loadq2() {
var del = document.getElementById("del");
del.onclick = divideAll;
}

function divideAll() {
var divisor = document.getElementById("divisor").value;
var div = document.getElementById("q2buttons");
while (div.firstChild.innerHTML % divisor == 0) {
div.removeChild(div.firstChild);
}
var button = div.firstChild;
while (button.nextSibling) {
if (button.nextSibling.innerHTML % divisor == 0) {
div.removeChild(button.nextSibling);
}
}
}

2 of 5
3. Ajax/XML
window.onload = loadq3;

function loadq3() {
ajaxHelper("movie.xml", displayLines);
}

function displayLines(ajax) {
var q3html = document.getElementById("q3html");
var character = ajax.responseXML.getElementsByTagName("character")[0];
var lines = character.getElementsByTagName("line");
for (var i = 0; i < lines.length; i++) {
var time = lines[i].getAttribute("time");
var text = lines[i].firstChild.nodeValue;
var p = document.createElement("p");
p.innerHTML = "(" + time + ") " + text;
q3html.appendChild(p);
}
}

3 of 5
4. PHP
<?php
include("q4top.html");

$name = $_POST["name"];
$cc = $_POST["cc"];
$pw = $_POST["pw"];

if ($name == "" || strlen($pw) < 6 ||


!preg_match("/^\d{4}[-]?\d{4}[-]?\d{4}[-]?\d{4}$/", $cc)) {
print("<h1>Denied! Invalid data.</h1>");
} else {
print("<h1>Successful.</h1>");
}
$cc = preg_replace("/-/", "", $cc);
$pw = preg_replace("/./", "*", $pw);
print("<p>$name, $pw, $cc</p>");

include("q4bottom.html");
?>

4 of 5
5. SQL
SELECT DISTINCT c1.Role
FROM Movie m1, Movie m2, Cast c1, Cast c2
WHERE c1.Role = c2.Role
AND c1.mid = m1.id
AND c2.mid = m2.id
AND m1.name LIKE "%Pirates of the Caribbean%"
AND m2.name LIKE "%Pirates of the Caribbean%"
ORDER BY c1.Role;
or:
SELECT DISTINCT c1.Role
FROM Movie m1, Movie m2, Cast c1, Cast c2
WHERE c1.aid = c2.aid
AND c1.mid = m1.id
AND c2.mid = m2.id
AND m1.name LIKE "%Pirates of the Caribbean%"
AND m2.name LIKE "%Pirates of the Caribbean%"
ORDER BY c1.Role;

5 of 5

You might also like