日期:2014-02-24  浏览次数:20573 次

PHP代码:--------------------------------------------------------------------------------
脚本说明:
把如下代码加入<body>区域中
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
oldvalue = "";
function passText(passedvalue) {
if (passedvalue != "") {
var totalvalue = passedvalue+"\n"+oldvalue;
document.displayform.itemsbox.value = totalvalue;
oldvalue = document.displayform.itemsbox.value;
}
}
// End -->
</script>
<form name="selectform">
<select name="dropdownbox" size=1>
<option value="">请选择</option>
<option value="第一项">第一项</option>
<option value="第二项">第二项</option>
<option value="第三项">第三项</option>
<option value="第四项">第四项</option>
<option value="第五项">第五项</option>
<option value="第六项">第六项</option>
</select>
<input type=button value="添加到列表中" onClick="passText(this.form.dropdownbox.options[this.form.dropdownbox.selectedIndex].value);">
</form>
<form name="displayform" >
<font face="Arial, Helvetica, Sans Serif" size="3"><b>你可以自己选择一下:</b></font><br>
<textarea cols="30" rows="5" name="itemsbox" >

PHP代码:--------------------------------------------------------------------------------
脚本说明:
把如下代码加入<body>区域中
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var delimiter = ":";
function MoveOption (MoveFrom, MoveTo, ToDo) {
var SelectFrom = eval('document.main_form.'+MoveFrom);
var SelectTo = eval('document.main_form.'+MoveTo);
var SelectedIndex = SelectFrom.options.selectedIndex;
var container;
if (ToDo=='Add') {
container=eval('document.main_form.'+ToDo+MoveTo);
}
if (ToDo=='Remove') {
container=eval('document.main_form.'+ToDo+MoveFrom);
}
if (SelectedIndex == -1) {
alert("请选择一个用户");
} else {
for (i=0; i<SelectFrom.options.length; i++) {
if(SelectFrom.options[i].selected) {
var name = SelectFrom.options[i].text;
var ID = SelectFrom.options[i].value;
SelectFrom.options[i] = null;
SelectTo.options[SelectTo.options.length]=new Option (name,ID);
i=i-1;
if(ToDo=='Add'||ToDo=='Remove') {
container.value=container.value+name+delimiter;
//container.value=container.value+ID+delimiter;
}
}
}
}
}
function CheckDuplicates (AddListContainer, RemoveListContainer) {
var AddList = eval('document.main_form.'+AddListContainer);
var RemoveList = eval('document.main_form.'+RemoveListContainer);
var TempAddList = AddList.value;
var TempRemoveList = RemoveList.value;
if (TempAddList>''&&TempRemoveList>'') {
TempAddList = TempAddList.substring(0,TempAddList.length-1);
TempRemoveList = TempRemoveList.substring(0,TempRemoveList.length-1);
var AddArray = TempAddList.split(delimiter);
var RemoveArray = TempRemoveList.split(delimiter);
for (i=0; i<AddArray.length; i++) {
for (j=0; j<RemoveArray.length; j++) {
if (AddArray[i]==RemoveArray[j]) {
AddArray[i]='';
RemoveArray[j]='';
break;
}
}
}
AddList.value='';
for (i=0; i<AddArray.length; i++) {
if (AddArray[i]>'') {
AddList.value = AddList.value + AddArray[i] + delimiter;
}
}
RemoveList.value='';
for (i=0; i<RemoveArray.length; i++)