mercredi 1 mars 2017

jQuery Get Multiple Checkbox Value and Pass to PHP

I have multiple checkbox below to add user access:

enter image description here

Each module have different ID. But now I confused how to get the checkbox value and then update it using ajax.

Example for
Module Location, I check Create and Edit.
Module Department I check Only View
(Have same group ID)

I didn't get the logic how to pass it to ajax and save it to database based on Module ID and Group ID.

Source code:

var tr_str = "<tr id='"+jsonStr[i].moduleID+"'>" +
"<td>" + projectName + "</td>" +
"<td>" + moduleName + "</td>" +
"<td align='center'><input type='checkbox' id='"+jsonStr[i].moduleID+"' name='chk[]' class='chk' value='CREATE'/><input type='hidden' id='groupIDInput' value='"+jsonStr[i].groupID+"'/></td>" +
"<td align='center'><input type='checkbox' id='"+jsonStr[i].moduleID+"' name='chk[]' class='chk' value='EDIT'/></td>" +
"<td align='center'><input type='checkbox' id='"+jsonStr[i].moduleID+"' name='chk[]' class='chk' value='VIEW'/></td>" +
"<td align='center'><input type='checkbox' id='"+jsonStr[i].moduleID+"' name='chk[]' class='chk' value='DELETE'/></td>" +
"</tr>";

What I want:
1. Get the checkbox value using ajax
2. Pass it to PHP to save to database.

Please advice.




Aucun commentaire:

Enregistrer un commentaire