Java Script in XHTML - Quiz #1

 

Problem #1: There are two messages that I have out into variables called myMsg and myOtherMsg.  You need to write these two messages onto the form on two different lines.

 

<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>JavaScript Quiz #1</title>

</head>

<body>

<h2>First question on JavaScript Quiz #1</h2>

<p>You should use JavaScript to write the two messages on different lines.</p>

<script type="text/javascript">

<!--

var myMsg = "This is the first part of may answer to question one";

var myOtherMsg = "This is the second part of my answer";

 

 

//-->

</script>

</body>

</html>

 

Problem #2:  Follow the instructions embedded in the program.

 

<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>JavaScript Quiz #1</title>

</head>

<body>

<h2>Second question on JavaScript Quiz #1</h2>

<p>In the JavaScript script, you need to define a second variable and assign that variable a

value of 6.<br />

You should then define a third variable to hold the results of multiplying firstNum by

by your second variable.  Remember that multiply is done with the *.<br />

Finally, in the script you should also write out a line containing a literal that says

THE ANSWER IS followed by a space and then you should show the results of the

multiplication.</p>

<script type="text/javascript">

<!--

var firstNum = 5;

 

 

 

//-->

</script>

</body>

</html>

 

 

Problem #3: Follow the embedded instructions.

 

<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>JavaScript Quiz #1</title>

</head>

<body>

<h2>Third question on JavaScript Quiz #1</h2>

<p>I have taken in an the on hand using a prompt. You need to take in the number sold. You

then need to calculate the difference (on hand minus the number sold) so that it will be

displayed with the document.write statement.</p>

<script type="text/javascript">

<!--

var onHand = window.prompt("Key in number on hand",0);

 

 

document.write("On Hand is now ", diff);

//-->

</script>

</body>

</html>

 

Problem #4: Write the code as explained inside the program.  Use the pictures of the screen to see what the results should look like.

 

<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>JavaScript Quiz #1</title>

</head>

<body>

<h2>Fourth question on JavaScript Quiz #1</h2>

<p>Write the JavaScript so the output looks like this.<br />  Note there is one

output if the pay is equal to or over 1000 and another output if it is less than 1000.</p>

<script type="text/javascript">

<!--

 

 

 

 

 

//-->

</script>

</body>

</html>

 

 

This screen above is asking the user to enter pay per hour.

 

The screen above shows the user entering 45.

 

 

The screen above is asking the user to enter in the hours worked.

 

The screen above shows the user entering in 40 for the hours worked.

 

The screen above shows the data that was entered and the results.  Notice that the pay is greater than 1000 so the message This pay is okay is generated and displayed.

Next I refresh and redo the program.  This time I enter 25 for the pay per hour and 20 for the hours worked.  The results are shown in the next screen shot.

 

Notice that the pay is less than 1000 so the message I want a raise is generated and displayed.