mardi 23 décembre 2014

The submit button should be enabled only when any checkbox is clicked using jQuery

I'm facing the following issue; the submit button should be enabled only when any checkbox is clicked. Using jQuery the code I have is:



$(document).ready(function() {
var the_terms = $("#pricingTierId");
the_terms.click(function() {
if ($(this).is(":checked")) {
$("#submitBtn").removeAttr("disabled");
} else {
$("#submitBtn").attr("disabled", "disabled");
}
});
});



<c:if test="${fn:length(incentiveList) gt 0}">
<input type='button' name="submit" id = "submitBtn" value='Submit Incentives' onClick='execute();' />
</c:if>


However in the checkbox code I have the following



<td>
<s:checkbox name="checkboxes[%{#stat.index}]" theme="simple" id="%{pricingTierId}"/>
</td>


my id attribute is defined as id="%{pricingTierId}" so I cannot really pass that in the JQery function as shown above. Please suggest the suitable way





Aucun commentaire:

Enregistrer un commentaire