mercredi 4 janvier 2017

Why does on click if checked malfunction after dealing with 2nd+ index in array

So i got this working with the first value x to be pushed and spliced but after it only pushes or doesn't do anything

<td> 
    <input type="checkbox" name="updateListings[]" value='+x+' onclick="doSomething(this)">
</td>

function doSomething(cb) {
    if ($(cb).is(":checked")) {
        uLIndex.push(cb.value);
        alert(uLIndex);
    } else {
        uLIndex.splice(cb.value, 1);
        alert(uLIndex);
    }       
}




Aucun commentaire:

Enregistrer un commentaire