Code: Select all
<html>
<head>
<title>Transfer List</title>
<script language="javascript">
function TransferList(l1,l2) {
if (l1.options.selectedIndex>=0) {
o=new Option(l1.options[l1.options.selectedIndex].text,l1.options[l1.options.selectedIndex].value);
l2.options[l2.options.length]=o;
l1.options[l1.options.selectedIndex]=null;
}else{
alert("Please select a course");
}
}
</script>
</head>
<body>
<?php
if (isset($_POST['Save'])){
// Place to save both listboxes
} // if (isset($_POST['Save']))
?>
<div align="center">
<form name="formulaire">
<TABLE>
<TR>
<TD align="center"><strong>Courses</strong><br />
<select name="CoursesList1" size=6 style="width:120px">
<option value="C++">C++</option>
<option value="VB6">VB6</option>
<option value="VB.NET">VB.NET</option>
<option value="C#">C#</option>
<option value="PHP">PHP</option>
<option value="Delphi">Delphi</option>
</select>
</TD>
<TD align="center">
<input type="button" value="Add >>>" onClick="TransferList(this.form.CoursesList1,this.form.CoursesList2)">
<br />
<br />
<input type="button" value="<<< Delete" onClick="TransferList(this.form.CoursesList2,this.form.CoursesList1)">
</TD>
<TD align="center"><strong>Courses</strong><br />
<select name="CoursesList2" size=6 style="width:120px">
</select>
</TD>
</TR>
</TABLE>
<input name="Save" type="submit" value="Save">
</form>
</div>
</body>
</html>It is easy to save a selected items (single or multiple) using PHP. In my case, I transfer one or more items from the first list to the second and save both lists (that means items are not selected).
Thanks