Jump to content

sending multiple checkbox values to server (PHP)


cougar23

Recommended Posts

I have a page that displays time slots people can sign up for by selecting checkboxes input elements.  for the <input> tag values, the "name"'s are the same, and the values are the date and time values of the time slot.  When I submit this form to the server (and have selected two or more checkboxes), only the most recently checked checkbox is coming through on my $_POST variable when it gets to the server. 

 

Here's the code I have on the page for the checkbox imput (this is inside of a loop that executes from a specified earliest time show to a latest time shown)

echo '<input type="checkbox" name="timeSlot" value="'.$date.';'.$startTime.';'.$endTime.'">';

 

Then server side I want to view all the checkboxes selected

//get the time slots the faculty member checked to be available for advising
$selectedTimeSlots = $_POST['timeSlot'];

echo $selectedTimeSlots;

 

So, for example, if I selected three checkboxes for the date 2008-11-17, for the times 8:00 AM-8:30 AM, 8:30 AM-9:00 AM, 9:00 AM-9:30 AM, the output of the variable server-side ($_POST['timeSlots']) is only the 9:00 AM-9:30 AM slot.

 

What am I doing wrong or how can I make the file do what I want to do, which is to have a collection of ALL the selected timeSlots?

 

Thanks in advance

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.