COSC 106 A, Web Programming Exam 3 Study Guide
Answers
Tom Linton, Spring 2004
The exam will cover chapters 9,10, and 11 of our text. If you can do most of the following problems in a timely fashion, with little help from the book, you should be well prepared for the exam.
Write the JavaScript fragments (just what is asked for, no surrounding tags needed) described below:
Write a JavaScript function named newBackground, which has three input parameters named red, green, and blue. The body of the function should set the background color of the web-page equal to the result of concatenating the three input parameters (so the function call newBackground("AA"," 08"," F6") would set the background color to #AA08F6).
Assuming that the source document has a form named formy, with one textbox named fahrenheitBox, and another named celsiusBox, write the JavaScript fragment that takes the value in fahrenheitBox, converts it to Celsius (use C = (F -32)*(5 / 9) to convert Fahrenheit temperatures to Celsius), displays the result in celsiusBox, and then places the focus on fahrenheitBox and selects the text displayed in fahrenheitBox.
Write a JavaScript function named randomScore which returns a random integer from 50 to 100 (no input parameters).
Change the source of the third image on the page to be the file batman.jpg (which is stored in the same folder as the source code document).
Round down the (number) variable named x, and multiply the result by the (number) variable y to the third power, saving the result int he variable x.
What is the final value of the variable x after the following
script is executed?
<script type="text/javascript"
language="JavaScript">
var x = 11;
x++;
x *= 2 + 6 / 3 + 2;
</script>
Consider the web-page shown below. It consists of a single form (name it formy) with 3 textboxes and a normal button. It is shown exactly as it would look when first loaded into a browser. Use the names (or ids) ageBox, yearsBox, and resultsBox for the names or ids of the three textboxes.