dimanche 26 février 2017

Multiple IF statements in ajaxSuccess giving the same result

Very simply put, in the ajaxSuccess part, of my GET method, for retrieving data, I have 12 ifs like so(part of the code):

 success: function (result) {
                if ((result.AppTime = "9:00") && (result.AppWithYritys = "Laakkonen")) {
                    document.getElementById("A9").style.background = "red";
                }
                if ((result.AppTime = "9:30") && (result.AppWithYritys = "Laakkonen")) {
                    document.getElementById("A930").style.background = "red";
                }
                if ((result.AppTime = "10:00") && (result.AppWithYritys = "Laakkonen")) {
                    document.getElementById("A930").style.background = "red";
                }
                if ((result.AppTime = "10:30") && (result.AppWithYritys = "Laakkonen")) {
                    document.getElementById("A930").style.background = "red";
                }
                if ((result.AppTime = "11:00") && (result.AppWithYritys = "Laakkonen")) {
                    document.getElementById("A930").style.background = "red";
                }

depending on the data retrieved from the database, it should color the appropriate div, as You can see, but it is coloring all of the divs and I know that the only thing that exists in the database and can be retrieved is the first if, only the first if is true. Am I doing something wrong?

Aucun commentaire:

Enregistrer un commentaire