I am a beginner in jquery so please bear with me.
I have a jquery function that allows me to select multiple checkboxes and create a string as follows:
function getSelectedVals(){
var tmp =[];
$("input[name='checks']").each(function() {
if ($(this).attr('checked'))
{
checked = ($(this).val());
tmp.push(checked);
}
});
var filters = tmp.join(',');
alert(filters)
return filters;
}
I then call a django view function and pass the string as follows:
selected = getSelectedVals();
var myurl = "/bills/delete/?id=" + selected;
$.ajax({
type: "GET",
url: myurl,
data: selected,
cache: false
});
On the server I have a delete view function that iterates over the checkbox values and manipulates a list.
def delete(request):
global myarray
idx = request.GET[u'id']
listidx = idx.split(',')
for l in listidx:
value = myarray[int(l)]
myarray.remove(value)
return HttpResponse("/bills/jqtut/")
The problem is that on the server all the indexes I am sending as the GET string are not being handled, only half are.
Please help me! Thanks