Page 2 of 2
Posted: Fri May 12, 2006 12:10 pm
by 4wood
OH no - we've run into another problem!
The DB now reads with Array in front of recipients....
How do I get the value of the individual option in the following:
<select name="mySelect[]" multiple="multiple">
...
</select>
I tried (to no avail):
document.formName.mySelect[0].options[0].value
document.formName.mySelect[].options[0].value
document.formName.mySelect[0].options[].value
Any ideas??

Posted: Fri May 12, 2006 12:42 pm
by RobertGonzalez
Try this and see what it does...
Code: Select all
<?php
$client_department_result = mysql_query("SELECT DISTINCT department_name FROM client_departments WHERE department_id='$department'") or die(mysql_error());
while($dept_row = mysql_fetch_array($client_department_result))
{
$client_department = $dept_row['department_name'];
}
// Format Recipient(s) section to include multiple selections
$recipients = $_POST['recipients'];
$db_recipients = ''; //string holder for your array string
if(is_array($recipients))
{
$counter = 0;
$delim = ', ';
$array_count = count($recipients);
while($counter < $array_count)
{
if ($counter == $array_count - 1)
{
$delim = '';
}
$db_recipients .= $recipients[$counter] . $delim;
$counter++;
}
}
/*
echo "<hr>GET<PRE>"; print_r($_GET); echo "</PRE>";
echo "<hr>POST<PRE>"; print_r($_POST); echo "</PRE>";*/
// Insert new rows into the db with the survey form information
$add_survey = "INSERT INTO reports(client_department, request_date, originator, recipients, reason, status, serial_id, comments)
VALUES('$client_department', '$requestDate', '$originators', '$db_recipients', '$reason', '$status', '$serialID', '$comments')";
mysql_query($add_survey) or die(mysql_error());
?>