左右列表框 传值。假如我点了全部向右后。右边的列表框就得到所有左边列表框的值。左边的清空。
我现在遇到的问题是。当我点了 全部向右后 然后选中右边框中的某项。向下。问题就在这里。假设我选择了右边框中的 短消息一项。点向下按钮 可以实现(该项跳到下面一行)。 我想继续让 短消息这项获得焦点。。无论我如何点短消息如果不是最后一行的话他总是往下跳,一直获得焦点。在我没有选择其他项之前。问题是我现在不知道如何获取焦点。
请各位大虾。指教了。
下面是我的代码,可以复制运行。。谢谢了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
<!-- 从左到右添加。从右往左添加-->
function trans(from,to){
fromList = eval('document.forms[0].'+ from);
toList = eval('document.forms[0].'+ to);
if(toList.options.length>0&&toList.options[0].value=="hello"){
toList.options.length=0;
}
for(var i=0;i<fromList.options.length;i++){
current = fromList.options[i];
var flag = false;
if(current.selected){
flag=true;
if(current.value=="hello"){
return ;
}
txt=current.text;
val=current.value;
toList.options[toList.length]=new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
}
<!--向上移动 -->
function forword (up){
high=eval('document.forms[0].'+up);
for(var i=1;i<high.options.length;i++){
current = high.options[i];
yes = high.options[i-1];
var flag =false;
if(current.selected){
flag=true;
txt1=yes.text;
var1=yes.value;
txt =current.text;
val =current.value;
high.options[i] =new Option(txt1,var1);
high.options[i-1]=new Option(txt,val);
}
}
}
<!--向下移动 -->
function comeback(down){
high=eval('document.forms[0].'+down);
if(toList.options.length>0&&toList.options[0].value=="temp"){
toList.options.length=0;
}
for(var i=0;i<high.options.length;i++){
current = high.options[i];
yes = high.options[i+1];
if(current.selected){
txt1=yes.text;
var1=yes.value;
txt =current.text;
val =current.value;
high.options[i] =new Option(txt1,var1);
high.options[i+1]=new Option(txt,val);
high.selectedIndex=current.selecteIndex+1;
}
}
}
<!-- 全部从左到右-->
function eachother(from,to){
fromList = eval('document.forms[0].'+ from);
toList = eval('document.forms[0].' + to);
if(toList.size>=0){
var a;
var b;
var x;
var y;
var current;
var yeah;
for(var z=0;z<toList.length;z++){
yeah=toList.options[z];
a=yeah.text;
b=yeah.value;
toList.options[z] = new Option(a,b);
}
for(var i =0;i<fromList.length;i++){ //判断 以前的是否有值
current = fromList.options[i];
x=current.text;
y=current.value;
toList.options[i] = new Option(x,y);
}
fromList.options.length=0;
}else {
for(var i =0;i<fromList.length;i++){
current = fromList.options[i];
x=current.text;
y=current.value;
toList.options[i] = new Option(x,y);
}
fromList.options.length=0;
}
}
<!--全部从右往左 -->
function eachother2(from,to){
fromList = eval('document.forms[0].'+ from);
toList = eval('document.forms[0].' + to);
if(toList.options.length>0&&toList.options[0].value=="hello"){
toList.options.length=0;
}
for(var i =0;i<fromList.length;i++){
current = fromList.options[i];
x=current.text;
y=current.value;
toList.options[i] = new Option(x,y);
//fromList.options[i] = null;
}
fromList.options.length=0;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="975" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="64" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="975" height="64"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="147" height="350" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="147" height="350" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table></td>
<td width="286" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="286" height="350" valign="top">
<select name="select1" style="width:100%; height:100%;" multiple="multiple" size="5">
<option value="1">通知</option>
<option value="2">常用网址</option>
<option value="3">网上调查</option>
<option value="4">最新上传文件</option>
<option value="5">快捷方式</option>
<option value="6">桌面便笺</option>
<option value="7">公司通讯录</option>
<option value="8">公共通讯录</option>
<option value="9">工作计划</option>
<option value="10">已收文件</option>
<option value="11">今日工作安排</option>
<option value="12">短消息</option>
<option value="13">个人通讯录</option>
</select>
</td>
</tr>
</table></td>
<td width="46" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="159" height="350" valign="top"><table width="45" border="0">
<tr>
<td width="39" height="57"><input type="button" name="Submit2" value="从左到右;" onclick="javascript:trans('select1','select2')" /></td>
</tr>
<tr>
<td height="58"><input type="button" name="Submit" value="从右到左" onclick="javascript:trans('select2','select1')" /></td>
</tr>
<tr>
<td height="74"><input type="button" name="Submit6" value="全部向右" onclick="eachother('select1','select2')" /></td>
</tr>
<tr>
<td height="72"><input type="button" name="Submit5" value="全部向左" onclick="eachother('select2','select1')"/></td>
</tr>
</table>
</td>
</tr>
</table></td>
<td width="364" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="364" height="350" valign="top"><select name="select2" style="width:100%; height:100%;"multiple="multiple" size="5">
<option value="temple">从左边区域选择</option>
</select></td>
</tr>
</table></td>
<td width="51" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="62" height="350" valign="top"><table width="84" height="351" border="1">
<tr>
<td width="74" height="91"><input type="button" name="Submit3" value="向上" onclick="forword('select2')" /></td>
</tr>
<tr>
<td height="60"><input type="button" name="Submit4" value="向下" onclick="comeback('select2')"/></td>
</tr>
<tr>
<td height="76"> </td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
<td width="81"> </td>
</tr>
</table>
</form>
</body>
</html>
我现在遇到的问题是。当我点了 全部向右后 然后选中右边框中的某项。向下。问题就在这里。假设我选择了右边框中的 短消息一项。点向下按钮 可以实现(该项跳到下面一行)。 我想继续让 短消息这项获得焦点。。无论我如何点短消息如果不是最后一行的话他总是往下跳,一直获得焦点。在我没有选择其他项之前。问题是我现在不知道如何获取焦点。
请各位大虾。指教了。
下面是我的代码,可以复制运行。。谢谢了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
<!-- 从左到右添加。从右往左添加-->
function trans(from,to){
fromList = eval('document.forms[0].'+ from);
toList = eval('document.forms[0].'+ to);
if(toList.options.length>0&&toList.options[0].value=="hello"){
toList.options.length=0;
}
for(var i=0;i<fromList.options.length;i++){
current = fromList.options[i];
var flag = false;
if(current.selected){
flag=true;
if(current.value=="hello"){
return ;
}
txt=current.text;
val=current.value;
toList.options[toList.length]=new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
}
<!--向上移动 -->
function forword (up){
high=eval('document.forms[0].'+up);
for(var i=1;i<high.options.length;i++){
current = high.options[i];
yes = high.options[i-1];
var flag =false;
if(current.selected){
flag=true;
txt1=yes.text;
var1=yes.value;
txt =current.text;
val =current.value;
high.options[i] =new Option(txt1,var1);
high.options[i-1]=new Option(txt,val);
}
}
}
<!--向下移动 -->
function comeback(down){
high=eval('document.forms[0].'+down);
if(toList.options.length>0&&toList.options[0].value=="temp"){
toList.options.length=0;
}
for(var i=0;i<high.options.length;i++){
current = high.options[i];
yes = high.options[i+1];
if(current.selected){
txt1=yes.text;
var1=yes.value;
txt =current.text;
val =current.value;
high.options[i] =new Option(txt1,var1);
high.options[i+1]=new Option(txt,val);
high.selectedIndex=current.selecteIndex+1;
}
}
}
<!-- 全部从左到右-->
function eachother(from,to){
fromList = eval('document.forms[0].'+ from);
toList = eval('document.forms[0].' + to);
if(toList.size>=0){
var a;
var b;
var x;
var y;
var current;
var yeah;
for(var z=0;z<toList.length;z++){
yeah=toList.options[z];
a=yeah.text;
b=yeah.value;
toList.options[z] = new Option(a,b);
}
for(var i =0;i<fromList.length;i++){ //判断 以前的是否有值
current = fromList.options[i];
x=current.text;
y=current.value;
toList.options[i] = new Option(x,y);
}
fromList.options.length=0;
}else {
for(var i =0;i<fromList.length;i++){
current = fromList.options[i];
x=current.text;
y=current.value;
toList.options[i] = new Option(x,y);
}
fromList.options.length=0;
}
}
<!--全部从右往左 -->
function eachother2(from,to){
fromList = eval('document.forms[0].'+ from);
toList = eval('document.forms[0].' + to);
if(toList.options.length>0&&toList.options[0].value=="hello"){
toList.options.length=0;
}
for(var i =0;i<fromList.length;i++){
current = fromList.options[i];
x=current.text;
y=current.value;
toList.options[i] = new Option(x,y);
//fromList.options[i] = null;
}
fromList.options.length=0;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="975" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="64" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="975" height="64"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="147" height="350" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="147" height="350" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
</table></td>
<td width="286" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="286" height="350" valign="top">
<select name="select1" style="width:100%; height:100%;" multiple="multiple" size="5">
<option value="1">通知</option>
<option value="2">常用网址</option>
<option value="3">网上调查</option>
<option value="4">最新上传文件</option>
<option value="5">快捷方式</option>
<option value="6">桌面便笺</option>
<option value="7">公司通讯录</option>
<option value="8">公共通讯录</option>
<option value="9">工作计划</option>
<option value="10">已收文件</option>
<option value="11">今日工作安排</option>
<option value="12">短消息</option>
<option value="13">个人通讯录</option>
</select>
</td>
</tr>
</table></td>
<td width="46" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="159" height="350" valign="top"><table width="45" border="0">
<tr>
<td width="39" height="57"><input type="button" name="Submit2" value="从左到右;" onclick="javascript:trans('select1','select2')" /></td>
</tr>
<tr>
<td height="58"><input type="button" name="Submit" value="从右到左" onclick="javascript:trans('select2','select1')" /></td>
</tr>
<tr>
<td height="74"><input type="button" name="Submit6" value="全部向右" onclick="eachother('select1','select2')" /></td>
</tr>
<tr>
<td height="72"><input type="button" name="Submit5" value="全部向左" onclick="eachother('select2','select1')"/></td>
</tr>
</table>
</td>
</tr>
</table></td>
<td width="364" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="364" height="350" valign="top"><select name="select2" style="width:100%; height:100%;"multiple="multiple" size="5">
<option value="temple">从左边区域选择</option>
</select></td>
</tr>
</table></td>
<td width="51" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="62" height="350" valign="top"><table width="84" height="351" border="1">
<tr>
<td width="74" height="91"><input type="button" name="Submit3" value="向上" onclick="forword('select2')" /></td>
</tr>
<tr>
<td height="60"><input type="button" name="Submit4" value="向下" onclick="comeback('select2')"/></td>
</tr>
<tr>
<td height="76"> </td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
<td width="81"> </td>
</tr>
</table>
</form>
</body>
</html>
楼主【BlackSky_Sun】截止到2008-07-29 12:16:07的历史汇总数据(不包括此帖):
发帖的总数量:23 发帖的总分数:320 每贴平均分数:13
回帖的总数量:15 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:22 结贴的总分数:270
无满意结贴数:9 无满意结贴分:260
未结的帖子数:1 未结的总分数:50
结贴的百分比:95.65 % 结分的百分比:84.38 %
无满意结贴率:40.91 % 无满意结分率:96.30 %
值得尊敬