I have the following code :
<form>
<input type="checkbox" name="type" value="Club" onclick="getselectedcheckbox()"checked/>Club<br/>
<input type="checkbox" name="type" value="Pub" onclick="getselectedcheckbox()" checked/>Pub<br/>
<input type="checkbox" name="type" value="Home" onclick="getselectedcheckbox()"/>Home<br/>
<input type="checkbox" name="type" value="Concert" onclick="getselectedcheckbox"/>Concert<br/>
<script>
function displayVals() {
var checkedValues = $('input:checkbox:checked').map(function() {
alert(this.value);
});
}
$( "select" ).change( displayVals );
displayVals();
</script>
I am trying to get all the checkbox checked, to then send it with ajax. But right now, I have 1 different alert for each checkboxes, is there a way to get all the checked values in one string ?
I've heard of .join(), but I don't really know where to put it in my code. Still beginning with Javascript / jquery :/
Any ideas ?
Thanks, Loneept