I’m trying to use jQuery to submit my form data but I can’t seem to get it quite right. Here is my jquery function:
$("#toremovefromlist").click(function() {
var ids = [];
$('#mailinglist :selected').each(function(i, selected){
ids[i] = $(selected).val();
});
$.post('toggleMailingList.php',
{'ids[]':ids ,'action':'remove','type':'entry'},
function(){
return !$('#mailinglist option:selected').remove().appendTo('#removelist');
}
);
});
#toremovefromlist is a button
#mailinglist is the first select box with multiple select enabled
#toggleMailingList.php is the destination script
#removelist is the second select box.
The idea is that one box has a list of people. A user selects people he wants to move to the other select box. When they hit the move button the people should move to the other select box and the data should be posted so that the change is made permanent (through database interaction). Any suggestions on what I’m doing wrong?