1

I'm trying to do something similar to this question. I want to send to the server the id's of the selected checkboxes. I'm using jquery only because the example. my ajax code is pure JS.

This is my code:

js:

function DeleteTest(ind)
 {
   if (confirm('Are you sure you want to delete this test?'))
      {
    ​   $(function() {
       var testdel = $('input[name=deletetest]').serialize();
       alert(testdel);
       window.open('test.php' + "?"+testdel,'_self');
           }   ​);
        return true;}
         else { return false;}
 }
  oCell.innerHTML = "<input type='checkbox' name='deletetest' value='"+ ind +   "')';>"; // create checkbox for each row in ajax

html:

<form id="checkboxform" action="test.php" method="post">
<tbody id="auditTblBody">
</tbody>
</table>
<input type="button" value="Submit AJAX Request" onclick="DeleteTest()" />
</form>

With this code i get only one value with GET.testdel is fine. (i.e deletetest=477&deletetest=476) my problem is how to send this information.

thank you!

2 Answers 2

2

For PHP to recognize multiple values from inputs with the same name, that name must end in the characters [].

  oCell.innerHTML = "<input type='checkbox' name='deletetest[]' value='"+ ind +   "')';>"; 
Sign up to request clarification or add additional context in comments.

2 Comments

The name has changed. You have to update the selector to match.
I changed to var testdel = $('input[name=deletetest[]]').serialize();
0
O/p: deletetest=477&deletetest=476

send the o/p in json format to a particular php file from javascript & you can decode it in redirected php file using json_decode

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.