MySQL Forums
Forum List  »  PHP

Re: Referencing Checkbox Form Values passed to a PHP form handler script
Posted by: Peter Brawley
Date: March 09, 2006 12:48PM

Not sure what "how would I test to know which vars of a set of checkboxes have been passed in and which were left out?" means. If the user checked it, the HTML form will pass it and the PHP page to which it's posted will pick it up. If it was there and she didn't check it, or if it wasn't there, the HTML form will not pass it. That's the HTML spec, I think.

If the PHP needs to know the diff netween a non-existent and uncheck checkbox, and if the PHP page is generic or for some other reason doesn't know what's on the form, you have to tell it. One way is, for every checkbox in the form, create a hidden form var from some prefix plus the checkbox's name, ie if you have cb1 through cb5, you would have hidden form vars p_cb1 through p_cb5 in the form, and in the PHP page you would write code to walk those p_cb* vars.

PB

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.