要下班了,时间太短,写了一个,基本功能实现了,你在自己测试下什么都不选等其他情况
<script language=javascript>
function d123()
{
var value=document.all.a123.options[document.all.a123.selectedIndex].value;
var text=document.all.a123.options[document.all.a123.selectedIndex].text;
document.all.a123.options[document.all.a123.selectedIndex]=null;
document.all.b123.options[document.all.b123.options.length]=new Option(value,text);
}
function e123()
{
var value=document.all.b123.options[document.all.b123.selectedIndex].value;
var text=document.all.b123.options[document.all.b123.selectedIndex].text;
document.all.b123.options[document.all.b123.selectedIndex]=null;
document.all.a123.options[document.all.a123.options.length]=new Option(value,text);
}
</script>
<select name=a123 size=5>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input name=c123 type=button value="-->" onclick=d123()>
<input name=f123 type=button value="<--" onclick=e123()>
<select name=b123 size=5>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
<script language=javascript>
function d123()
{
var value=document.all.a123.options[document.all.a123.selectedIndex].value;
var text=document.all.a123.options[document.all.a123.selectedIndex].text;
document.all.a123.options[document.all.a123.selectedIndex]=null;
document.all.b123.options[document.all.b123.options.length]=new Option(value,text);
}
function e123()
{
var value=document.all.b123.options[document.all.b123.selectedIndex].value;
var text=document.all.b123.options[document.all.b123.selectedIndex].text;
document.all.b123.options[document.all.b123.selectedIndex]=null;
document.all.a123.options[document.all.a123.options.length]=new Option(value,text);
}
</script>
<select name=a123 size=5>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input name=c123 type=button value="-->" onclick=d123()>
<input name=f123 type=button value="<--" onclick=e123()>
<select name=b123 size=5>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
解决方案 »
- jquery及ajax 都验证通过 为什么这个方法最后返回false,急死了
- 通过这个例子,看看你是不是真正知道为什么js叫"java"script...
- firebug调试工具怎么查看一个对象的所有方法属性
- checkbox 如何遍历 取值成数组或字符串传递到action中?
- IE 6.0 下面 Cookie问题
- 求正则表达式
- 如何使控件变灰?
- javascript下能否得到当前服务器地址
- 我在一个输入框中输入几行文字,在输入框旁边有个按钮,一按,这几行文字就自动变成列表格式,再提交,应该怎么做。。。
- 为什么不响应onchange事件
- 急求:根据鼠标坐标获得它悬停某个标签上,该标签的属性
- 关于层的叠加问题,谢谢!
1、select框的长度可以指定吗?(因为数据都是从数据库中读取的,如果不是固定的话,很不方便)
2、想在请求在同一select框中,上移、下移的功能代码。
1
2
3
4
move up move down
可以指定的
<select name=a123 style="width:100">
</select>
上移下移的代码,五分钟后你再来看看
function d123()
{
if(document.all.a123.selectedIndex!=0)
{
var value=document.all.a123.options[document.all.a123.selectedIndex].value;
var text=document.all.a123.options[document.all.a123.selectedIndex].text;
var value1=document.all.a123.options[document.all.a123.selectedIndex-1].value;
var text1=document.all.a123.options[document.all.a123.selectedIndex-1].text;
var selectedIndex=document.all.a123.selectedIndex;
var upselectedIndex=document.all.a123.selectedIndex-1 document.all.a123.options[selectedIndex]=new Option(value1,text1);
document.all.a123.options[upselectedIndex]=new Option(value,text);
}
}
function e123()
{
if(document.all.a123.selectedIndex!=document.all.a123.options.length)
{
var value=document.all.a123.options[document.all.a123.selectedIndex].value;
var text=document.all.a123.options[document.all.a123.selectedIndex].text;
var value1=document.all.a123.options[document.all.a123.selectedIndex+1].value;
var text1=document.all.a123.options[document.all.a123.selectedIndex+1].text;
var selectedIndex=document.all.a123.selectedIndex;
var upselectedIndex=document.all.a123.selectedIndex+1 document.all.a123.options[selectedIndex]=new Option(value1,text1);
document.all.a123.options[upselectedIndex]=new Option(value,text);
}
}</script>
<select name=a123 size=5>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input name=c123 type=button value="上移" onclick=d123()>
<input name=f123 type=button value="下移" onclick=e123()>
http://community.csdn.net/Expert/topic/4256/4256470.xml?temp=.8794824可否给我发些js的学习资料,[email protected]