I have a group of checkboxes deefined by path deliveryStatus as shown below
<form:checkbox path="deliveryStatus" value="notDelivered"/>
<form:checkbox path="deliveryStatus" value="delivered"/>
I read two examples which are very nice
I notice the ID comes as deliveryStatus1 and deliveryStatus2 and not deliveryStatus
Therefore when using the way mentioned in example #2 (for parent tag ID) I get no result.
What is the correct way to get the selected/checked checkbox for my form(deloveryStatus) in jquery/ajax.
I noticed below code works after I realized IDs to be deliveryStatus1 and deliveryStatus2
var deliverystatus = $('#deliveryStatus1').val();
alert( 'deliverystatus' );
deliverystatus = $('#deliveryStatus1').is(":checked");
alert( deliverystatus );
deliverystatus = $('#deliveryStatus2').is(":checked");
alert( deliverystatus );
But do not feel this is the correct way to get the checked option
Aucun commentaire:
Enregistrer un commentaire