A few words of thanks would be greatly appreciated.

PHP - Retrieving data from a checkbox


I have a form in PHP . This form contains checkbox which I would like to retrieve the value via an Ajax function . I worked over it all night but I still cannot retrieve these values.

Here is my php transformed into html (just the relevant part):

<form id='form_affectation' onsubmit='affecter(4); vider_div("tableau_logiciels_salles"); return false;'> <input type=checkbox name='salle_id' value=6/> A099 (C2M - Denis Papin) < br> <input type=checkbox name='salle_id' value=5/> B020 (C2M - Denis Papin) <br> <input type=checkbox name='salle_id' value=4/> B055 (C2M - Science) <br > <input type=checkbox name='salle_id' value=2/> C100 (C2M - Denis Papin) <br> <input type=checkbox name='salle_id' value=7/> C134 (C2M - Science) <br> <input type='submit' value='Afficher'> </ form> 

and here is the code of my JavaScript:

function assign (id_logiciel) {var en = new Array (); room = $ ("# form_affectation). find (" input [name = salle_id] "). val (); alert (salle.length) $. post ("jQuery / affecter.php", {room: room} function success (data) {$ ('# tableau_affectation'). html (room);});} 


function assign (id_logiciel, nbrCheckbox) {var = nbrCheckbox nbrCheckbox; for (i = 1; i <= nbrCheckbox; i + +) {var currentCheckbox = document.getElementById ("salle_" + i) if (currentCheckbox.checked) {alert ( currentCheckbox.name + "is checked");}} return false;} 


Solved by Vodkadaaa


A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « PHP - Retrieving data from a checkbox », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).