<html>
<head>
<script language="JavaScript">
<!--
function addSrcToDestList() {
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
if (srcList.options[i].text == destList.options[count].text) {
found = true;
break;
}
}
}
if (found != true) {
destList.options[len] = new Option(srcList.options[i].text);
len++;
}
}
}
}function deleteFromDestList() {
var destList = window.document.forms[0].destList;
var len = destList.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
destList.options[i] = null;
}
}
}
// -->
</SCRIPT>
</head>
<body>
<center>
<form method="POST">
<table bgcolor="#FFFFCC"><tr>
<td bgcolor="#FFFFCC" width="85">
<select size="6" name="srcList" multiple>
<option value="1">Item 1
<option value="2">Item 2
<option value="3">Item 3
<option value="4">Item 4
<option value="5">Item 5
<option value="6">Item 6
</select>
</td>
<td bgcolor="#FFFFCC" width="74" align="center">
<input type="button" value=" 增加到右边 " onClick="javascript:addSrcToDestList()">
<br><br>
<input type="button" value=" 从右边删除 " onclick="javascript:deleteFromDestList();">
</td>
<td bgcolor="#FFFFCC" width="69">
<select size="6" name="destList" multiple>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
<head>
<script language="JavaScript">
<!--
function addSrcToDestList() {
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
if (srcList.options[i].text == destList.options[count].text) {
found = true;
break;
}
}
}
if (found != true) {
destList.options[len] = new Option(srcList.options[i].text);
len++;
}
}
}
}function deleteFromDestList() {
var destList = window.document.forms[0].destList;
var len = destList.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
destList.options[i] = null;
}
}
}
// -->
</SCRIPT>
</head>
<body>
<center>
<form method="POST">
<table bgcolor="#FFFFCC"><tr>
<td bgcolor="#FFFFCC" width="85">
<select size="6" name="srcList" multiple>
<option value="1">Item 1
<option value="2">Item 2
<option value="3">Item 3
<option value="4">Item 4
<option value="5">Item 5
<option value="6">Item 6
</select>
</td>
<td bgcolor="#FFFFCC" width="74" align="center">
<input type="button" value=" 增加到右边 " onClick="javascript:addSrcToDestList()">
<br><br>
<input type="button" value=" 从右边删除 " onclick="javascript:deleteFromDestList();">
</td>
<td bgcolor="#FFFFCC" width="69">
<select size="6" name="destList" multiple>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
怎么给分?如果我的数据来自SQL的查询呢?
{
var oSeleSrc;
var oSeleDest = document.all("selRoleUser")
oSeleSrc = document.all("selUserList");
AddSelectedItem(oSeleSrc,oSeleDest)
}function removeUserFromSelect()
{
var oSele = document.all("selRoleUser")
DeleteSeletedItem(oSele);
}function AddSelectedItem(oSelSrc,oSelDest)
{
try
{
var iIndexSrc,iIndexDest;
var sValue,sInnerText;
var isExistItem;
var oOption;
var sArr,sUserID,sUserName,sUserType;
var isGroup = false;
if(oSelSrc.selectedIndex == -1)
return false; for(iIndexSrc = 0; iIndexSrc < oSelSrc.options.length; iIndexSrc ++)
{
if(oSelSrc.options(iIndexSrc).selected)
{ isExistItem = false;
sValue = oSelSrc.options(iIndexSrc).value; for(intIndexDest = 0; intIndexDest < oSelDest.options.length; intIndexDest ++)
{
if(oSelDest.options(intIndexDest).value == sValue)
{
isExistItem = true;
}
}
if(!isExistItem)
{
oOption = document.createElement("OPTION");
oSelDest.options.add(oOption);
oOption.innerText = oSelSrc.options(iIndexSrc).innerText;
oOption.value = sValue;
oOption = null;
}
}
}
return true;
}
catch(e)
{
alert(e.description);
}}function DeleteSeletedItem(objSeleDel)
{
try
{
var intIndex;
var intLength;
intLength = objSeleDel.options.length;
if(objSeleDel.selectedIndex == -1)
return false; var sValue;
var sArr,sUserID;
for(intIndex = 0; intIndex < intLength; intIndex ++)
{
if(objSeleDel.selectedIndex != -1)
{
sValue = objSeleDel.options(objSeleDel.selectedIndex).value;
objSeleDel.options.remove(objSeleDel.selectedIndex);
}
} return true;
}
catch(e)
{
alert(e.description);
}
}
function addallUserToSelect()
{
removeallUserFromSelect()
i=0
for (i=0;i<document.all.selUserID.length;i++)
{
oOption = document.createElement("OPTION");
document.all.selRoleUser.options.add(oOption);
oOption.innerText = document.all.selUserID.options(i).innerText;
oOption.value = document.all.selUserID.options(i).value;
oOption = null;
}
}
function removeallUserFromSelect()
{
lengths=document.all.selRoleUser.length;
for(i=0;i< lengths;i++)
{
document.all.selRoleUser.options.remove(0);
}
}
</script>
<body>
<div align="center">
<center>
<table border="0" width="100" cellspacing="1">
<tr>
<td width="16%">
<select id="selUserList" size="1" name="selUserID" multiple style="width: 120; height: 140" ondblclick="document.all.addoption.onclick();">
<option value="1">aaaaa</option>
<option value="2">bbbbb</option>
<option value="3">ccccc</option>
<option value="4">ddddd</option>
<option value="5">eeeee</option>
<!--如果是从SQL数据库中取数据,你可以在这里面循环输出类似下面这样:
<%do while not rs.eof%>
<option value="<%rs("namevalue")%>"><%rs("name")%></option>
<%
rs.movenext
loop
%>
其中,“rs”为记录集,“rs("namevalue")”和“rs("name")”为相关的显示字段
-->
</select>
</td>
<td width="19%">
<input class="userbutton" type="button" value=" 增加>>" name="addoption" onclick="addUserToSelect()"><br>
<input class="userbutton" type="button" value="<<删除 " name="deloption" onclick="removeUserFromSelect()"><br>
<input class="userbutton" type="button" value=" 全加>>" name="addalloption" onclick="addallUserToSelect()">
<input class="userbutton" type="button" value="<<全删 " name="delalloption" onclick="removeallUserFromSelect()">
</td>
<td width="65%">
<select id="selRoleUser" size="1" name="selRoleUser" multiple style="width: 120; height: 140" ondblclick="document.all.deloption.onclick();">
</select></td>
</tr>
</table>
</center>
</div>
</body>
include ("../../lib/setting.php");PangRight($SAS_SESSION[userlogin][spwd]);
//echo $enname."<br>".$cnname;exit;
?>
<html>
<head>
<title>GROUP JOB</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo ${CHARSET_.$SAS_SESSION[language]}; ?>">
<?php echo ${css_.$SAS_SESSION[language]}; ?>
<SCRIPT LANGUAGE="JavaScript">
<!-- function Input(){ if (document.dataform.otherjob.value == ""){
window.alert("ÖÁÉÙÑ¡ÔñÒ»¸öÔö¼ÓÏî!");
return false;
}
form = document.dataform;
var result="";
for (var i=0;i<form.otherjob.length;i++)
{
if (form.otherjob.options[i].selected)
{
result+=form.otherjob.options[i].value+",";
}
}
document.dataform.key.value=result;
document.dataform.sendtype.value='input';
document.dataform.submit();
}
function Output(){ if (document.dataform.thisjob.value == ""){
window.alert("ÖÁÉÙÑ¡ÔñÒ»¸öÒƳýÏî!");
return false;
}
form = document.dataform;
var result="";
for (var i=0;i<form.thisjob.length;i++)
{
if (form.thisjob.options[i].selected)
{
result+=form.thisjob.options[i].value+",";
}
}
document.dataform.key.value=result;
document.dataform.sendtype.value='output';
document.dataform.submit();
} //-->
</SCRIPT></head><body>
<center>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="Td8">
<table width="0" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="Td8" width="19"> </td>
<td class="Td8a"><b>ºǫ́¹ÜÀí--×é±ð¹ÜÀí--²¿ÃÅȨÏÞ</b></td>
<td class="Td8" width="48"> </td>
<td class="Td8"> </td>
</tr>
</table>
</td>
<td width="10" class="Td8"> </td>
</tr>
</table>
</center>
<form name="dataform" method="post" action="groupjobcode.php">
<INPUT TYPE="hidden" name="sendtype">
<input type="hidden" name="enname" value="<?php echo $enname;?>">
<input type="hidden" name="cnname" value="<?php echo $cnname;?>">
<INPUT TYPE="hidden" name="key"> <div align="center">
<table width="98%" border="0" cellpadding="0" cellspacing="2" class="Font12px">
<tr class="Fnt12px">
<td valign="top"> <table width="100%" border="0" cellspacing="1" cellpadding="0" class="Font12px">
<tr class="Td5" align="center">
<td width="20%">
Ó¢ÎÄ×éÃû
</td> <td width="40%">
ÖÐÎÄ×éÃû
</td>
</tr>
<tr class="Td6">
<td>
<? echo $enname; ?>
</td>
<td>
<? echo $cnname; ?>
</td>
</tr>
</table>
</td>
</tr>
<tr class="Fnt12px">
<td valign="top"> <table width="100%" height="270" border="0" cellspacing="1" cellpadding="0" class="Font12px">
<tr bgcolor="#cccccc" align="center">
<td width="50%" height="20"class="Td3">ÒÔ·ÖÅ乤×÷</td>
<td class="Td3">δ·ÖÅ乤×÷</td>
</tr> <tr align="center">
<td width="50%" class="Fnt12px" class="Td4">
<select name="thisjob" multiple size="15">
<?php
$CONFIG->query="select * from groupjob,operation where groupjob.groupname='".$enname."' and operation.operationid = groupjob.operationid order by groupjob.operationid asc";
//echo $CONFIG->query;exit;
$result_i=db_query("select");
$totalrows=count($result_i)-1;
if ($totalrows!=0){
for ($j=0;$j<$totalrows;$j++)
{
echo '<option value="'.$result_i[$j][operationid].'">'.$result_i[$j][operationnm].'</option>';
}
}else{
echo '<option> </option>';
}
?>
</select>
</td> <td class="Fnt12px" class="Td4">
<select name="otherjob" multiple size="15">
<?php
$CONFIG->query="select operation.* from operation left join groupjob on operation.operationid = groupjob.operationid and groupjob.groupname='".$enname."' where groupjob.operationid IS NULL order by operation.operationid asc";
$result_o=db_query("select");
$rows=count($result_o)-1;
if ($rows!=0){
for ($i=0;$i<$rows;$i++)
{
echo '<option value="'.$result_o[$i][operationid].'">'.$result_o[$i][operationnm].'</option>';
}
}else{
echo '<option> </option>';
}
?>
</select>
</td>
</tr> <tr align="center">
<td width="50%" height="35">
<INPUT TYPE="button" class="ipsub" value=" >> " onClick="javascript:Output()">
</td> <td>
<INPUT TYPE="button" class="ipsub" value=" << " onClick="javascript:Input()">
</td>
</tr> <tr align="center">
<td colspan="2" height="30">
<INPUT TYPE="button" class="ipsub" value=" ·µ »Ø " onclick="javascript:window.location.href='groupindex.php'">
</td>
</tr>
</table> </td>
</tr> </table> </div>
<INPUT TYPE="hidden" name="select" value="for checkbox group: javascript,var 'select' array one">
</form></body>
</html>
include ("../../lib/setting.php");PangRight($SAS_SESSION[userlogin][spwd]);
//echo $enname."<br>".$cnname;exit;if (count($HTTP_POST_VARS)>0){
$form=$HTTP_POST_VARS;
$form[key]=trim_char($form[key]);
$listvalue=explode(",",$form[key]);
$count=count($listvalue);
switch ($form[sendtype]){
case input:
for($i=0;$i<$count;$i++){
$CONFIG->query="insert into groupjob (groupname,operationid) values ('".$form[enname]."','".$listvalue[$i]."')";
//echo $CONFIG->query;
db_query();
}
break;
case output:
for($i=0;$i<$count;$i++){
$CONFIG->query="delete from groupjob where operationid='".$listvalue[$i]."' and groupname='".$form[enname]."'";
db_query();
}
break;
}
}///////////////////////////////////////////////////////////////////////////////////////////////
Header("Location:groupjobindex.php?enname=".$form[enname]."&cnname=".$form[cnname]);
///////////////////////////////////////////////////////////////////////////////////////////////
?>