samedi 3 octobre 2015

From IF/ELSE to Switch in Javascript

So, I'm trying to substitute the code within the IF statements to run the same way in a Switch statement. However, I can't seem to understand how to get the functions to run the same way in the switch as they do in the if statement. Here's the code I've written with the if statement. Could anyone help me figure out how to format it correctly to run with the switch statement instead?

function processInput() {

    listitem = "item" + i;
    document.getElementById(listitem).innerHTML = document.getElementById('toolBox').value;
    document.getElementById('toolBox').value = '';

    if (i == 5) {

      document.getElementById('resultsExpl').innerHTML = "Thanks for your suggestions";

    }
    i++;
}

Aucun commentaire:

Enregistrer un commentaire