PDA

View Full Version : using prototype's ajax, need help with checkboxes



ahs10
01-17-2008, 04:23 PM
i think i may be thinking this too hard, but here's what i've come up
with that doesn't work. i have an undefined amount of checkboxes in
the document below that are generated by php during a while loop.
that loop gives each one a unique id (check0, check1, check2, etc).
i'm trying to initiate an ajax request, but in it's parameters send a
variable that contains a list of all the checked checkboxes.

my idea here is to send the checkedYes variable as a parameter with
the request. it would be a string containing the list of checked
checkboxes, separated by a ~ which i could explode in the php that
receives the request.

it doesn't work. when i click on the button that runs this function
and supplies the user name, nothing happens. i stuck an alert('i am
here'); at the very beginning of the function, tried it and it didn't
give me a popup either. besides the fact that my mind leans towards
the server side....what's wrong? below is client side source that the php outputs. i can post my php, if that would help too.....


function assignUser(userName) {
var searchCount=14
var
checkBoxNames='check0~check1~check2~check3~check4~check5~check6~check7~chec k8~check9~check10~check11~check12~check13~'
var tSplit=checkBoxNames.split('~')
var checkedYes=''
for (var j = 0; j < searchCount; j++) {
var tj=tSplit[j]
if (document.getElementById(tj).checked) {
checkedYes=checkedYes+'~'+tj
}
}
new Ajax.Request('../php/assignUser.php',
{
method:'post',
parameters: {userName: userName, location: location, checkedYes:
checkedYes},
onSuccess: function(transport) {
document.title="Records Successfully Assigned"
new Effect.BlindUp('adminAssign');
document.getElementById('dynaDiv_searchResults').innerHTML=transport.respon seText
},
onFailure: function() {
alert('Ruh Roh!');
}
});
}