jquery - Cycle Through Javascript Vars -


~~~solved~~~

thanks community rewrote question maker automatically make array , can confirm after doing , referencing array works perfectly!

~~~end solution~~~

i again sure simple solution after hours of coding can't find! lol. javascript follows:

function startgame() {   var x = 999;   var qquesnum = 1;   var qquesval = ('q' + qquesnum + 'question');   (var qgs=1; qgs <= tq; qgs++) {     $("body").append('<div id="q' + (qgs) + '" class="question" style="z-index: ' + x + ';"><h2 class="questionnum">question ' + (qgs) + '</h2><br /><p class="question' + (qgs) + '"></p><input type="button" onclick="cycleremove()" value="done" class="removebutton"></div>');     x = (x-1);     qquesnum = (qquesnum + 1);   };   $('.file').toggle();   $('.question').toggle(); }; 

the file in user uploads , div created has whole list of vars such as:

var q#question = "{question data here}"; 

where "#" real number such 1, 2, 3, 4, etc...

the script @ top executed after user uploads file website var's defined. can not figure out how var q#question show in between paragraph tags , cycle way through q#question variables.

you can use eval, however, using eval never idea. if can, rewrite game use array of question objects instead.

for (var qgs=1; qgs <= tq; qgs++) {     var qquesval = eval('q' + qgs + 'question');     // append code } 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -