|
-
Feb 15th, 2005, 08:06 PM
#1
Thread Starter
Addicted Member
Simple JS Question
I cant get this to work. Any help!?
Code:
<HTML>
<HEAD>
<TITLE>Web Exercise 2</TITLE>
<script type="text/javascript" Language="JavaScript">
<!--
var correctAnswer = new Array(10);
correctAnswer[0] = "B";
correctAnswer[1] = "A";
correctAnswer[2] = "B";
correctAnswer[3] = "B";
correctAnswer[4] = "B";
correctAnswer[5] = "B";
correctAnswer[6] = "B";
correctAnswer[7] = "A";
correctAnswer[8] = "A";
correctAnswer[9] = "A";
function getSelectValue(webex2,selectname){
var theMenu = document[webex2][selectname];
var selecteditem = theMenu.selectedIndex;
return theMenu.options[selecteditem].value;}
function checkAnswers() {
var score = 0;
for (i= 1; i<11; i++) {
answer = getSelectValue("webex2","q" + i);
if (I NEED HELP HERE!!!! == correctAnswer[i]) {
score++;
}
}
document.webex2.scorefield.value = score;
}
//-->
</script>
</HEAD>
<BODY bgcolor="white">
<HR>
</HR>
<H1>MIS 428 WEBEX2</H1>
<form name="webex2">
<h4>
1.The width of all data cells in a HTML table must be the same.
<select name="q1">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
2.The body of a for structure must be enclosed in curly braces ({ and }).
<select name="q2">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
3.The default case in a switch structure is always executed.
<select name="q3">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
4. A switch structure begins execution immediately after executing the statements
in the body of a case.
<select name="q4">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
5. When a do/while structure is encountered in a program, its body is guaranteed to
execute twice.
<select name = "q5">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
6. While using the STYLE tags, and describing an attribute, the equal (=) sign means the same thing as a colon (:) sign.
<select name = "q6">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
7. The right side of a logical AND (&&) operator is always evaluated regardless of whether
the condition on the left side of the operator is true or false.
<select name = "q7">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
8. All variables declared in the body of a function and the parameters to a function are
considered to be local variables by a JavaScript.
<select name = "q8">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
9. Most functions have a list of parameters that provide the means for communicating
information between functions via function calls.
<select name = "q9">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select>
<BR></BR>
10. The fifth element of an array can be accessed with the expression a[ 4 ].
<select name = "q10">
<option selected>Select your answer</option>
<option value="A">True</option>
<option value="B">False</option>
</select><BR></BR>
<hr><p><input type="button" value="Check Answers" onclick=checkAnswers();></P>
<p>Your score is:<input type="text" name="scorefield" value=" " size="10"></p>
</form>
</BODY>
</HTML>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|