syntax error - Javascript not running -


i have code here:

var questions=[] questions[0]=["what answer?",["a","b","c","d"],3] questions[1]=["what answer?",["a","b","c","d"],3] questions[2]=["what answer?",["a","b","c","d"],3] questions[3]=["what answer?",["a","b","c","d"],3]  function createquestions(id) {     var treturn="<form>"     treturn=treturn+"<b>questions "+id+":</b>"      treturn=treturn+"</form>"     return treturn; }  (i=0;i<4;i++) {     var elem=document.getelementbyid('quiz_section')     var func=createquestion(i)     elem.innerhtml=elem.innerhtml+func+"<br />" } 

i started using javascript recently. know there must syntax error in here somewhere can't find it. there is, in fact div in main document id of "quiz_selection".

i don't have access kind of debugger because i'm @ school , blocked.

thanks if can!

your function named createquestions calling createquestion. otherwise syntax seems fine.

additionally, if code embedded page may not function because document not exist when loop executes; hence quiz_section div not exist.

enclose loop in function so:

function initializequiz() {     (i=0;i<4;i++) {         var elem=document.getelementbyid('quiz_section')         var func=createquestions(i)         elem.innerhtml=elem.innerhtml+func+"<br />"     } } 

and add onload='javascript:initializequiz()' attribute <body> tag.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -