0

I have a list that is coming from the db and creates a list of checkbox inputs. When the user clicks on the checkbox it will populate only that item. What I want to do to begin with is check the status of the checkbox. If it's checked I want to console.log the systemId and the operator name to compare to make sure they match. here is my code:

        $(".wellProducer").click(function(){
            if(this.checked == true){
                console.log(wells["SystemId"]);
                console.log(wellProducers["Operator"]);
            }
        });

The .wellProducer is the class of the input checkbox. What I have populating right now is all the systemId's and operators, but I want to compare them to see if they match.

2
  • Do you want to compare each element of the first array and see if the equal to every element of the second one? Commented Nov 9, 2016 at 17:23
  • @nicovank yes I do.. I want to see if SystemsId = Operator.. and the ones that equal each other, then console.log them Commented Nov 9, 2016 at 17:30

1 Answer 1

2
for(var i = 0; i < wells.SystemId; i++) {
    if (wells.SystemId[i] == wells.Operator[i]) {
        console.log(wells.SystemId[i]);
    }
}

Asuming they are strings, and that they are put in the same order. Otherwise comment this answer and I'll see what I can change to make it work.

Sign up to request clarification or add additional context in comments.

1 Comment

how do I check the status of the check box to see if it's been checked, then run this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.