<html>
<head>
<script>
function addstafflist()
{
for(var i = 0; i < document.getElementById("stafflist").options.length; i++)
{
if(document.getElementById("stafflist").options[i].selected)
{
var staffname = document.getElementById("stafflist").options[i].text;
var selectedstaffnamelist = document.getElementById("selectedstafflist");
var found = false;
for(var j = 0; j < selectedstaffnamelist.length; j++)
{
if(selectedstaffnamelist[j].text == staffname)
{
found = true;
break;
}
}
if(!found)
{
var option = document.createElement("option");
option.text = staffname;
selectedstaffnamelist.add(option);
}
}
}
</script>
</head>
<body>
<form action="test2.php" method="post">
<table border="0" width="300" style="border-collpase:collapse">
<tr>
<td width="50">
<select id="stafflist" name="stafflist[]" style="width:70px;" multiple>
<option value="ali@gmail.com">ali</option>
<option value="abu@gmail.com">abu</option>
<option value="ahmad@gmail.com">ahmad</option>
</select>
</td>
<td width="30">
<input type="button" name="add" value=">>" onclick="addstafflist()" />
</td>
<td>
<select id="selectedstafflist" name="selectedstafflist[]" style="width:70px;" multiple>
</select>
</td>
</tr>
<tr height="20">
<td colspan="3">
<input type="submit" name="submit" value="Show" />
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
//[HERE]
}
?>
From above code, when I select ali, abu from the drop down list and click the Show button, I want to use PHP to show their email addresses (i.e ali@gmail.com, abu@gmail.com) after click the Show button in [HERE] section. Can someone help me?