Sounds like a job for Javascript. Try adapting these functions. 1st, give your checkboxes the name "checkboxes". 2nd, give them each a unique id. 3rd, create a hidden text input field named "idstring" and put it inside a form. It will hold the string returned.
Hope this helps.
function collectCheckedItems()
{
var checkboxes = document.getElementsByName("checkboxes")
var idstring = ""
for( i=0 ; i < checkboxes.length ; ++i )
{
if( checkboxes[ i ].checked )
idstring = idstring + checkboxes[ i ].id + ","
}
if( idstring.length > 0 )
idstring = idstring.slice( 0 , idstring.length - 1 )
return idstring
}
function SubmitForDeletion()
{
var idstringfield = document.getElementById("idstring")
idstringfield.value = collectCheckedItems()
if( idstringfield.value.length == 0 )
{
alert( "No records checked for deletion." )
return false
}
}
j_70 wrote:I have a simple example of my form:
<html>
<head><title></title></head>
<body>
<table>
<form method="POST" action="checkboxes.php">
<tr>
<td>
Choose Event
</td>
</tr>
<tr>
<td>
Soccer Game
</td>
<td>
<input name="Choice[]" type="checkbox" value="1">
</td>
<td>
<input name="Date[]" type="textbox" value="01/01/2007">
</td>
</tr>
<tr>
<td>
Baseball Game
</td>
<td>
<input name="Choice[]" type="checkbox" value="2">
</td>
<td>
<input name="Date[]" type="textbox" value="01/01/2007">
</td>
</tr>
<tr>
<td>
Basketball Game
</td>
<td>
<input name="Choice[]" type="checkbox" value="3">
</td>
<td>
<input name="Date[]" type="textbox" value="01/01/2007">
</td>
</tr>
<tr>
<td>
<input type="submit" value="submit">
</td>
</tr>
</form>
</table>
</body>
</html>
Since the date fields are filled in, they are being sent in the _POST array, irrespective of when the 'Choice' checkbox has been selected. If I choose two of the three checkboxes, the resultant arrays are:
Array ( [0] => 1 [1] => 2 )
Array ( [0] => 01/01/2007 [1] => 01/01/2007 [2] => 01/01/2007 )
How do I just get the dates that correspond to the checkboxes that were selected??