jeudi 7 septembre 2017

JS How to match a value from one DOM element with id of other DOM element

function newFunction(element){
        var period  = document.getElementById('period').value;
        for(var l = 0; l < period; l++){
            var valueEnteredID = document.getElementById('time' +l);
            var valueEnteredCLASS = document.getElementsByClassName('time' +l);
            if(valueEnteredID == valueEnteredCLASS){
                var valueEntered = element.value;
                var timeEntered = document.getElementById(???)
            };
        };
    };

So I have this function, the problem is timeEntered. It is in a for loop and I want to get all ids in that loop, and match them with valueEntered. If we have a match I want to alert the value of the input timeEntered.

here is a screenshot of it:

Aucun commentaire:

Enregistrer un commentaire