I NEED HELP

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

31-Jul-10 01:48
i hav this project net to be submitted next week

its a java script problem, i need to make a quiz with 5 multible choice and 4 match quistions and both the answers and quistions must show up randomly wvery time the page is reloaded


i hav been working on it for almost 2 days and its not working well , i posted in another forum and they only respond it's wrong

So Please HELP ME


the code i made so far:

<html> <head> <script>

var score=new Array();

var MCQ =new Array ("What is the only function all C++ programs must contain?<br/>",
"What punctuation is used to signal the beginning and end of code blocks?<br/>",
"What punctuation ends most lines of C++ code?<br/>",
"Which of the following is the correct operator to compare two variables?<br/>",
"Which of the following is not a correct variable type?<br/>");


var Q1=new Array("<form id=\"q1\"><input type=\"radio\" name=\"A\" value=\"A\"/> <label>start()</label><br/>",
"<input type=\"radio\" name=\"B\" value=\"B\"/><label>system()</label> <br/>",
"<input type=\"radio\" name=\"C\" value=\"C\" onClick=score[0]=1 /> <label>main()</label><br/>",
"<input type=\"radio\" name=\"D\" value=\"D\"/> <label>program()</label></form><br/> <br/>");

var Q2=new Array("<input type=\"radio\" name=\"c\" value=\"A\" onClick=\"score[1]=1\"/> <label>{ }</label><br/>",
"<input type=\"radio\" name=\"c\" value=\"B\"/><label>-> and <-</label>",
"<br/><input type=\"radio\" name=\"c\" value=\"C\"/> <label>BEGIN and END</label><br/>",
"<input type=\"radio\" name=\"c\" value=\"D\"/> <label>(and)</label> <br/> <br/>");




var Q3=new Array("<input type=\"radio\" name=\"c\" value=\"A\"/> <label>(dot)</label><br/>",
"<input type=\"radio\" name=\"c\" value=\"B\" onClick=\"score[2]=1\" /><label>;(Semi colon)</label>",
"<br/><input type=\"radio\" name=\"c\" value=\"C\"/> <label>:(Colon)</label><br/>",
"<input type=\"radio\" name=\"c\" value=\"D\"/> <label>'(Single quote)</label> <br/> <br/>");



var Q4=new Array("<input type=\"radio\" name=\"c\" value=\"A\"/> <label>:=</label><br/>",
"<input type=\"radio\" name=\"c\" value=\"B\"/><label>=</label>",
"<br/><input type=\"radio\" name=\"c\" value=\"C\"/> <label>Equal</label><br/>",
"<input type=\"radio\" name=\"c\" value=\"D\" onClick=\"score[3]=1\"/> <label>==</label> <br/> <br/>");




var Q5=new Array("<input type=\"radio\" name=\"c\" value=\"A\"/> <label>float</label><br/>",
"<input type=\"radio\" name=\"c\" value=\"B\" onClick=\"score[4]=1\"/><label>real</label>",
"<br/><input type=\"radio\" name=\"c\" value=\"C\"/> <label>int</label><br/>",
"<input type=\"radio\" name=\"c\" value=\"D\"/> <label>double</label> <br/> <br/>");









function DisplayQuestions() {


dis: for(var i=0;i<100;i++) {
var Q = Math.floor(Math.random()*5);

if(MCQ[Q]==null)
continue dis;
else {

document.writeln( MCQ[Q]);

if(Q==0){

ans1: for(var j=0;j<=100;j++){
var r = Math.floor(Math.random()*4);
if(Q1[r]==null)
continue ans1;
else {document.writeln(Q1[r]);
Q1[r]=null;} document.write("<br/>") }
}

else if(Q==1){
ans2: for(var a=0;a<=100;a++){
r = Math.floor(Math.random()*4);
if(Q2[r]==null)
continue ans2;
else {document.writeln(Q2[r]);
Q2[r]=null;} document.write("<br/>");}
}//end if



if(Q==2){
ans3: for(var a=0;a<=100;a++){
r = Math.floor(Math.random()*4);
if(Q3[r]==null)
continue ans3;
else {document.writeln(Q3[r]);
Q3[r]=null;} document.write("<br/>");}
}//end if



if(Q==3){
ans4: for(var a=0;a<=100;a++){
r = Math.floor(Math.random()*4);
if(Q4[r]==null)
continue ans4;
else {document.writeln(Q4[r]);
Q4[r]=null;} document.write("<br/>");}
}//end if




if(Q==4){
ans5: for(var a=0;a<=100;a++){
r = Math.floor(Math.random()*4);
if(Q5[r]==null)
continue ans5;
else {document.writeln(Q5[r]);
Q5[r]=null;} document.write("<br/>");}
}//end if

} MCQ[Q]=null;

document.write("<br/>"); }}

DisplayQuestions()



function CheckAns(){

for(var i=0;i<5;i++)
var total=total+score[i];
document.write("the total is= "+total);
}

</script>
</head>
<body>






<input type = "submit" name = "submit" value = "Submit" onClick="CheckAns()" /> <input type = "reset" name = "reset" value = "Reset"
</body></html>

--
Life
01-Aug-10 17:26
Hi there,

1) Please use a more meaningful topic subject than "I need help".

2) Please don't write your subject in ALL CAPITAL LETTERS. This is considered shouting, and people are likely to ignore you.

3) Please give an exact description of the problem, including any error messages.

4) Please use the code ("<>") button above the message box to format your code so that it's easier for us to read.

Then we might be able to help you.

Thanks,
Matt

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/

 
New posts
Old posts

Follow Elated