Pass array to function, how?
<p>I have some code that does not quite work as I assumed it would. I am still very much in the learning process, and the code probably looks terrible to some of you. Hopefully you can disregard that and help me out still.</p>

<p>I have constructed a function that turns the columns green once a checkbox is checked, and red when they are not checked. I then push the GREEN values into an array, and return it, when clicking on "add" which looks like this (<code>&lt;input type="button" id="submit" value="Send data" onclick="sendData(sendMe)"&gt;</code>) I expect it to loop through and alert the values (sendData-function) but nothing happens. If I take the code INSIDE the sendData function and place it in the "ChangeBackGroundColor" it works, but I would like to submit it using XHTMLrequest.</p>

<pre><code>function ChangeBackgroundColor(status){
    if (status.checked) {
        status.parentNode.style.backgroundColor = "green";
        sendMe = [];
        status.parentNode.previousSibling.style.backgroundColor ="green";
        status.parentNode.previousSibling.previousSibling.style.backgroundColor ="green";
        status.parentNode.previousSibling.previousSibling.previousSibling.style.backgroundColor ="green";
        sendMe.push(status.parentNode.previousSibling.textContent);
        sendMe.push(status.parentNode.previousSibling.previousSibling.textContent);
        sendMe.push(status.parentNode.previousSibling.previousSibling.previousSibling.textContent);

                }
    else {
        status.parentNode.style.backgroundColor = "red";
        status.parentNode.previousSibling.style.backgroundColor ="red";
        status.parentNode.previousSibling.previousSibling.style.backgroundColor ="red";
        status.parentNode.previousSibling.previousSibling.previousSibling.style.backgroundColor ="red";
        sendMe.pop(status.parentNode.previousSibling.textContent);
        sendMe.pop(status.parentNode.previousSibling.previousSibling.textContent);
        sendMe.pop(status.parentNode.previousSibling.previousSibling.previousSibling.textContent);


    }
    return sendMe;

}

function sendData(sendMe) {

    var arrayLength = sendMe.length;
    for (var i = 0; i &lt; arrayLength; i++) {
    alert(sendMe[i]);

        }
</code></pre>