Problem with checkbox

liunx

Guest
I'm coding with php page and I 'm doing a form to psot information to the server.<br />
<br />
I'M trying to send an array of checkbox so it's easy to recover<br />
My problem is the html form doesn't send the information of a non checked checkbox<br />
ex:<br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" CHECKED><br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" ><br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" CHECKED><br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" ><br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" ><br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" ><br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" ><br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" CHECKED><br />
yo :<INPUT TYPE="checkbox" NAME="AfficheAcceuil[]" CHECKED><br />
<br />
If I send that form it will return a array of 4 all 4 checked on<br />
but how can I know witch one of the nine is the one checked...<br />
What I was thinking was to give a value 1 to a checked one and 0 to a non checked checkbox?? <br />
Can someone light me up on that one thanks<!--content-->I've never used php before, but why not just use a different name for each checkbox instead of using an array? Each one could be named AfficheAccueil0, AfficheAccueil1, etc... Then when you get your email it will tell you which ones were checked.<br />
<br />
Hope this helps,<br />
Kyle<!--content-->i dont think get will send values for non-checked boxes: it's just not how forms work.<br />
<br />
if you know how many boxes there are though (and they dont change) then you can test for it with php - just do a loop which searches for the ones that havent come through.<br />
<br />
Just out of interest though, what are the circumstances where you'd want to get the ones that aren't checked?<!--content-->i'm creating template in php. It's a page with newspaper article so I need an article title and an article text area so I create a textbox for the title and a text area for article on the site I'm creeating I need to ask the person who's creating the page if he want to show that article on the main page that where the checbox come in place. I got to submit button on that page that send to itself one is use if the guy wants to add more articleso if he wnat another set of form to add he click so I send all information back to the same page with a new set of box for the new article everything is loaded with a for command. That where my problem come in my checkbox are all mees up for the text he doesnt mess he send an empty textbox but not an empty chexckbox<!--content-->well I'm not sure that that has made it any clearer, but i think kleg has a valid point - if you actually call the check boxes something different (you can still use an array if you wish, just make each checkbox an element within the array), then you'll get returned which check boxes are filled. You can then add all the news stories to your database, and on your front page you can do a query which only returns the articles with checks.<br />
<br />
At least i think that's what you wanted to do - you may want to spend a little more time and care explaining it if i've got the wrong end of the stick. Also, if your problem is PHP based then you'd be wise to check out the growing formun which is at <!-- w --><a class="postlink" href="http://www.phpbuilder.com/board">www.phpbuilder.com/board</a><!-- w --><!--content-->thanks for your help my best option was to change the checkbox for combobox... For the one who want's more information on my probelm I did attach the source code it's in php but was creating html form so there you go<!--content-->
 
Back
Top