mercredi 6 mars 2019

String + an incremental value in JavaScript

I've added comments at the middle of the code. Please help me If you can, I have to deliver the product today.

 if (a == 3) { //this would be how many of the answers further the action
                 var starting = 2; // for an example: yes or no; two of the answers go to no, one goes to yes. 
                 //                                  we take 2 as a starting point /you can set these individually for each scenario;
                 if (starting = 2) {
                     for (i = 0; i < starting; i++) {
                         answers[i] = 1; //sets the two checking points of the answer to the no, remaining yes;
                         var n = "btn" + i.toString()
                         document.getElementById(n).style.backgroundColor = "red";

     // the problem lies here
    // I tried multiple ways but none of them worked so far
    //i want to apply the style change to multiple buttons at once.

                     }

                     alert(answers);

                     for (i = 0; i < starting; i++) {
                         if (answers[i] == 1) {

                         }
                     }

                 }
             }




Aucun commentaire:

Enregistrer un commentaire