So I want to submit only when a checkbox is checked (I want to do something else when a checkbox is unchecked). I've been trying to get this checkbox submit to work but not no avail. Here's what I have:
$('#checkbox').click(function() { if ($(this).attr('checked')) { $("#form").submit(function () { var newvals = $("#form").serialize(); // serialize data $.post('save.php', newvals, function(data) { $("#content").html(data); }); // posting data and dumping response onto page return false; }); } else { alert(2); // placeholder for what i want to do otherwise } }); I looked around and was poking around with .trigger and .live, but I'm having problems even thinking about how the logic would even work with those functions. I'm not opposed to using them as long as I can distinguish between a 'checked' box and an 'unchecked' box.
Any ideas?