<title>
列表数据交换
</title><script language="JavaScript">function copyToList(from,to) {
fromList = eval('document.forms[0].' + from);
toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('你不能选择这个项目!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
if (!sel) alert ('你还没有选择任何项目');
}
function allSelect() {
List = document.forms[0].chosen;
if (List.length && List.options[0].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options[i].selected = true;
}
}
</script>
<table border="0">
<tbody>
<tr class="firstRow">
<td>
<select name="possible" size="4" multiple="" width="200" style="width: 200px"><option value="1">
长沙
</option>
<option value="2">
天津
</option>
<option value="3">
南京
</option>
<option value="4">
武汉
</option>
<option value="5">
郑州
</option></select>
</td>
<td>
<a href="javascript:copyToList('possible','chosen')">--><br/>
<br/>
</a><a href="javascript:copyToList('chosen','possible')"><--</a>
</td>
<td>
<select name="chosen" size="4" multiple="" width="200" style="width: 200px;"><option value="temp">
选择地区
</option></select>
</td>
</tr>
</tbody>
</table>