Reputation: 1795
I have a PHP question. I am trying to alter some code that a partner of mine wrote (he has since then left and cannot be contacted) but I am not hugely familiar with PHP. I believe that the question will be fairly simple but I am not sure where to start. Currently there is a drop down menu that allows you to select only one option. I BELIEVE the code that is involved in that process is here:
<select id='List' style='width:75px' onchange='displayEx(this);'>
<option value="0">list</option>
<?php
foreach ($LIST as $list)
{
echo "<option value='$list'>$list</option>";
}
echo "</select>";
?>
<select id='selectd' style='width:75px'>
<option value="0">X</option>
</select>
<input id="addTest" type="button" value="Add" onclick="addTest();"/>
<p id='error_display' style="height:10px;"></p>
<div>
<?php
$i = 1;
foreach ($Groups as $G)
{
echo "<div style='float:left;width:30%;height:100px;display:inline'><p id='Group $i' title='$G'>Group $G:</p><p id='display_Group_$i'>0/94</p><input id=\"get_Group_$i\" type=\"button\" value=\"Create\" onclick=\"createSheet($i);\" disabled = \"true\" style=\" vertical-align:bottom; display:inline;\"/></div>";
$i++;
}
?>
</div>
But I am not sure what to do with it. I was thinking something like this...
foreach ($select as $value)
{
echo '<option';
if (isset($_POST['select']) && $_POST['select'] == $value)
SOMETHING HERE
}
I don't know though. Other peoples code can sometimes be so confusing (particularly in a language you aren't the best at). For my sanity I hope someone can help me puzzle this out but even if someone could help me translate the current code I would be super grateful.
Upvotes: 0
Views: 2307
Reputation: 2455
Use multiselect for the select tag
<select multiple="multiple">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
Upvotes: 1