Re: POST checkbox group



..oO(Richard Walker)

Trying to send the data from a checkbox group to a php process and it's
just sending the last box clicked as a variable, rather than the whole
group as an array. Am I being stupid?

ie html:

<form name="selectform" action="data.php" method="post">
<input name="days" type="checkbox" value="mon" />Mon
<input name="days" type="checkbox" value="tue" />Tue
<input name="days" type="checkbox" value="wed" />Wed
<input type="submit" name="Submit" value="Submit" />
</form>

Use name="days[]". Then $_POST['days'] will be an array, containing the
values of all checked checkboxes.

Micha
.



Relevant Pages

  • Re: nested conditional that can identify parent page?
    ... and specify the files in the array including ... try to make as little php and html mix as possible, have a template ...
    (alt.php)
  • Re: Proper coding? (JS newbie)
    ... Document content looks like HTML 4.01 Transitional ... also in the FAQ. ... array; one fewer thing to change if another button is added. ... Use W3C standard ...
    (microsoft.public.scripting.jscript)
  • Re: printing an image of a form
    ... I know "here" is a stupid ... name for a link but it was just a quick example of the html code I was ... If you have a problem with printing images, ... Jukka K. Korpela ...
    (alt.html)
  • Re: Can a default value be specified for a drop-down list?
    ... Theo wrote: ... > HTML requires the particular menu choice to be listed as 'selected'. ... add php code to each choice. ... > The line using a php array is ...
    (comp.lang.php)
  • Re: create array from members of an array of objects
    ... $listis an array of MyElement objects. ... I'm working together with another person who is not a programmer: he's an HTML author and I need to make the code structure as essential as possible. ... $aValues is an array containing the key-value couples to be displayed in the select. ... This way, my friend, who does not know php, is able to move the select anywhere on the page by simply moving the php code line, and I do not risk to have my code corrupted by a mistake by my friend. ...
    (comp.lang.php)