I have several checkbox with different Id's. and a text area named taSignOff. The trigger is invoked once checkbox is ticked / checked. Was wondering why this code is not working in Chrome or IE? In firefox, it runs smoothly.
Here's the code.
var selectedvalue=[];
function checkTickArea(id)
{
$('#'+id).change(function () {
//If checked then push the value
if( $('#'+id).is(":checked"))
{
selectedvalue.push($('#'+id).attr("value"));
}else
{
//This is what pops the value from the array when the checkbox is unchecked.
/* var index = selectedvalue.indexOf($('#'+id).attr("value"));
if (index > -1) {
selectedvalue.splice(index, 1);
}*/
selectedvalue.splice(selectedvalue.indexOf($(this).attr("value")),1);
}
document.getElementById('taSignOff').value = selectedvalue.join("->\n");
});
}