I have multiple forms on this page I am optionally submitting with ajax. Problem is only the first object select by jQuery is being executed!
Here's the js:
$(function() {
var input = 'table td input[type="checkbox"]';
var form = 'form.update_done';
var isDone = 0;
$(input).each(function() {
if($(this).attr('checked')) { $(this).parents('tr').removeClass('unDone'); }
else { $(this).parents('tr').addClass('unDone'); }
});
$(input).each(function() {
$(this).click(function update() {
if($(this).attr('checked')) {
isDone = 1;
$(form).submit();
$(this).parents('tr').removeClass('unDone');
}
else {
isDone = 0;
$(form).submit();
$(this).parents('tr').addClass('unDone');
}
});
});
$(form).submit(function() {
$.post(
'set_done.cfm',
{ id: $('input[name="id"]').val(), done: isDone },
function(responseText){
// $(this).parents('tr').toggleClass('unDone');
},
"html"
);
return false;
});
});
and the html:
<td>
<form class="update_done">
<input type="hidden" name="id" value="#jobs.id#" />
<input type="checkbox" <cfif jobs.done IS 1>checked="checked" </cfif>/>
</form>
</td>
Anyone know where I went off track? If I wasn't very clear, please let me know.