tags:

views:

22

answers:

3

Hi all,

I have a form with some different input elements. One of these is a checkbox array. Adding another checkbox to the array using Jquery, without reloading the page I cannot see my checked checkbox on $_POST?

Is there any way to add extra input fields with values, and then catching these in a $_POST?

Thanks in advance

+1  A: 

Adding another checkbox to the array using Jquery, without reloading the page I cannot see my checked checkbox on $_POST?

You can not see/fill the super array $_POST dynamically, you need to submit the form either via ajax or through a submit button.

The reason for this is that $_POST is part of PHP not jQuery and since PHP is a server-side scripting language, you need to make a trip to the server.

In your case, you might want to submit the form via ajax, for example, jQuery's $.ajax method and this will include newly as well as existing elements in the submission process.

Sarfraz
A: 

you should be able to see the checkboxes in that array given that:

  • the checkboxes arent disabled when you submit the form
  • the checkboxes are added to the correct form
  • the checkboxes have name attributes set correctlty
mkoryak
A: 

Thanks for your responses! I believe I didn't explain myself well enough, and that might have lead to some confusion.

I build the example from scratch, and that solves my question- it is doable. I must have some other code in my script that's preventing it from working.

See my example below: http://pastie.org/1077627

kris