The below code is used in a PHP page to create a selections list and it works for us. But now we would need to get the selection list to be multiselect.
How the code would need to be updated so that it would work as multiselect?
function createSelectionList($controlName, $table, $valueColumn, $descriptionColumn, $mandatory=false) {
global $conn, $tokens_Select;
$cssClass = 'trafficFormItem';
if($mandatory) {
$cssClass .= 'm';
}
$selectListSql = "SELECT ".$valueColumn.", ".$descriptionColumn." FROM ".$table." ORDER BY ".$descriptionColumn;
$selectListRs = &$conn->Execute($selectListSql);
if (!$selectListRs) {
echo('<span style="color: #cc0000;>An error occured: '.$conn->ErrorMsg().'</span>');
}else {
echo('<select name="'.$controlName.'" id="'.$controlName.'" class="'.$cssClass.'">');
echo('<option value="" selected>('.$tokens_Select.'...) </option>');
while (!$selectListRs->EOF){
echo('<option value="'.$selectListRs->fields[0].'">'.$selectListRs->fields[1].'</option>');
$selectListRs->MoveNext();
}
echo('</select>');
}
}
<select multiple>
will let you select multiple values in a select box.
Hold down the Ctrl (windows) / Command (Mac) button to select multiple options.
In you code change the add multiple
to the following line
echo('<select multiple name="'.$controlName.'" id="'.$controlName.'"
class="'.$cssClass.'">');