mardi 1 mars 2016

PHP checkbox value when onchange.submit form

I have a PHP webpage that shows all the things I need to work on, coming from a database. At the far end of the line, there's a checkbox that by default is not checked.

What I want is that when I've done the thing, I come to that form and click on the checkbox. Then, it should automatically submit the form (the whole "table" is a form and I use onClick="document.forms['form_todo_list'].submit() on every checkbox) and I want to recover the value from this one and only checkbox that I've checked so that it saves the change into the db (using PHP and mySQL) and then the page refreshes itself and that checkbox is now shown as checked.

However, when I try to use the PHP test if (isset($_POST[''])) it doesn't work and it goes directly to the "else" instructions.

It seems like when I click on the checkbox, the form is submitted before the value is changed...

Could it be possible ?

PS: I'm not posting any code here because I don't think it's necessary. I don't think there's a problem in the code I have written, but rather in the process I'm trying to think of or maybe there's something I don't know about how the onChange (or onClick) works... Thanks again in advance for your help !




Aucun commentaire:

Enregistrer un commentaire