[jQuery] Re: checkboxes, array and $.post

2009-01-04 Thread Joe
$(':submit').click(function(){ var serial = $('form').serialize(); var subVal = $('#submitButton').val(); var param = $('#submitButton').attr('name'); var data = serial + subVal + param; $.post("delete.php", data, function(){ ... }); }); That should do it. Joe http://www.subprint.com On J

[jQuery] Re: checkboxes, array and $.post

2009-01-02 Thread jjshell
You rock Ricardo! :) Thank you very much. Just one last question. The submit button (#submitButton) doesn't seem to be serialized along with other fields... And I need its value. How would you add it to the post collection? Regards, -jj. On 1 jan, 22:03, Ricardo Tomasi wrote: > That's what s

[jQuery] Re: checkboxes, array and $.post

2009-01-01 Thread Ricardo Tomasi
That's what serialize() is for: $(':submit').click(function(){ var data = $(this).parents('form:first').serialize(); // or $('#formID').serialize(); $.post("delete.php", data, function(){ ... }); }); On Jan 1, 8:48 am, jjshell wrote: > Hi Ricardo, thanks for your reply. > I think I

[jQuery] Re: checkboxes, array and $.post

2009-01-01 Thread jjshell
Hi Ricardo, thanks for your reply. I think I must be missing something when it comes to $.post a form in jQuery. It seems too complicated to have to do something like this: $.post("delete.php",{ field1: $("#field1").val(), field2: $("#field2").val(), fiel

[jQuery] Re: checkboxes, array and $.post

2008-12-31 Thread Ricardo Tomasi
Assuming you have unique names: var CheckedIDs = []; $("input.items_id").livequery('click',function(event){ $("input.items_id").each(function() { if (this.checked) { CheckedIDs[this.name] = $(this).attr ("value"); } else { CheckedIDs[this.name] = null } }); })

[jQuery] Re: checkboxes, array and $.post

2008-12-31 Thread jjshell
Ok I'm getting closer... And thanks again for your help :) I can manage to have the checked checkboxes added to the CheckedIDs array. However, if I uncheck a checkbox, it is not removed from the array. It's the last little problem I have to solve :) Here's my code: var CheckedIDs = []; $

[jQuery] Re: checkboxes, array and $.post

2008-12-31 Thread Joe
I don't believe you are using livequery in the proper way. You're passing an 'each' event, which does not exist here. In theory, you could do the following: $("input.item_id").livequery('foo',function(bar) { alert('nothing happens'); }); In the console, you will see the length of the wrapped s

[jQuery] Re: checkboxes, array and $.post

2008-12-31 Thread jjshell
The problem seems to be located around these parts: var CheckedIDs = []; $("input.item_id").livequery('each',function(add) { if (this.checked){ alert('push'); CheckedIDs.push($(this).attr("value")); } }); On 31 déc, 15:26, jjshell wrote: > Thanks for your reply :) > >

[jQuery] Re: checkboxes, array and $.post

2008-12-31 Thread jjshell
Thanks for your reply :) I only get the alert nothing selected though... Tried to go through the code, couldn't find what is wrong... Regards, -jj. On 31 déc, 14:51, MorningZ wrote: > Not sure if it's the *best* way, but it works > > I'd do something like > > var CheckedIDs = []; > $("input.i

[jQuery] Re: checkboxes, array and $.post

2008-12-31 Thread MorningZ
Not sure if it's the *best* way, but it works I'd do something like var CheckedIDs = []; $("input.item_id").each(function() { if (this.checked) { CheckedIDs.push($(this).attr("value")); } }); if (CheckedIDs.length == 0) { alert("Nothing selected!"); } else { $.post( "de