就这点分就想拿来砸人?!?
http://jkisjk.vip.sina.com/html/moveRightOrLeft.htm
http://jkisjk.vip.sina.com/html/moveRightOrLeft.htm
解决方案 »
- 请问下activeXObject
- function 在哪些地方写?,然后调用。。求解
- 用showModalDialog显示出来的对话框怎样查看源代码?怎样调试?
- js做的新闻小偷 大家看看 帮解决个小八哥
- 如何用javascript实现真正的仿outlook菜单
- 在页面上单击一个按钮 ,将本页收藏为书签的方法?
- frameset问题并求一限制文本框只可以输入2000-01-12的正则表达式
- javascript疑问?
- javascript中如何判断是润年由此方法吗?
- 有没有大神知nuxt 不能像 vue 一样使用 localstorage, 有什么解决办法,网上搜到的 99.9% 都是用户登录状态的列子,但是我要储存很多数据
- 两个javascript问题
- fso问题
<select name="sortsele" size="10" style="WIDTH: 200px" multiple>
<option value="1" >liu</option>
<option value="2" >liu1</option>
<option value="3" >liu2</option>
<option value="4" >liu3</option>
<option value="5" >liu4</option>
<option value="6" >liu5</option>
<option value="7" >liu6</option>
<option value="8" >liu7</option>
<option value="9" >liu8</option>
<option value="10" >liu9</option>
</select>
<input type="button" value="上" onclick="uup()" name="up" />
<input type="button" value="下" onclick="ddp()" name="down"/>
</form>
<script language='javascript'>
//upup
function uup()
{
var sel=document.forms[0].sortsele;
if(!sel) return false;
if(sel.length<0)return false;
if(sel.selectedIndex<=0) return false;
t_value=sel.options[sel.selectedIndex-1].value
t_text=sel.options[sel.selectedIndex-1].text
sel.options[sel.selectedIndex-1].value= sel.options[sel.selectedIndex].value
sel.options[sel.selectedIndex-1].text= sel.options[sel.selectedIndex].text
sel.options[sel.selectedIndex].value=t_value;
sel.options[sel.selectedIndex].text=t_text;
}
//dndn
function ddp()
{
var sel=document.forms[0].sortsele;
if(!sel) return false;
if(sel.length<0)return false;
if(sel.selectedIndex>=sel.length-1) return false;
t_value=sel.options[sel.selectedIndex+1].value
t_text=sel.options[sel.selectedIndex+1].text
sel.options[sel.selectedIndex+1].value= sel.options[sel.selectedIndex].value
sel.options[sel.selectedIndex+1].text= sel.options[sel.selectedIndex].text
sel.options[sel.selectedIndex].value=t_value;
sel.options[sel.selectedIndex].text=t_text;
}
</script>没考虑多选,如果可以多选换位,根据需要自己写程序吧。
比如下面select中:
<select name=ObjSelect size=6 style="font-size:11pt;width=200;height=160px" multiple >
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>
<option value="4">test4</option>
<option value="5">test5</option>
<option value="6">test6</option>
</select>
想获取此列表中所有数据要怎么写呢?
包括取得value和”test1“之类的结果,或者单取value,不过取得全部的option的value
//首先全选这个select,然后提交标单。
function sss()
{
var sel=document.forms[0].sortsele;
if(!sel) return false;
if(sel.length<0)return false;
for(var i=0;i<sel.length;i++)
{
sel.options[i].selected=true;
}
document.forms[0].submit();
}</script>
var str="";
var sel=document.forms[0].sortsele;
for(var i=0;i<sel.options.length;i++){
str+=sel.options[i].value+",";
}
document.forms[0].iHidden.value=str;
用字符串应该比较灵活些
1,2,3,4,5,6
test1,test2,test3,test4,test5,test6
这样到后台一split就可以了
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>新用户注册</title>
<script language="javascript" type="text/javascript">
function optMove(num){
var dlt=document.getElementById("dltSort");
//alert(dlt.selectedIndex);
if(dlt.selectedIndex < 0) return ;
if((dlt.selectedIndex==0 && num==-1) || (dlt.selectedIndex == (dlt.options.length-1) && num==1)) return;
var opt=dlt.options[dlt.selectedIndex];
var opt1=dlt.options[dlt.selectedIndex+num];
chg(opt,opt1);
opt1.selected=true;
}
function chg(opt1,opt2){
var tmp="";
tmp=opt1.value; opt1.value=opt2.value; opt2.value=tmp;
tmp=opt1.text; opt1.text=opt2.text; opt2.text=tmp;
}
</script>
</head><body ><select id="dltSort" size="6">
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>
<option value="4">test4</option>
<option value="5">test5</option>
</select>
<input type="button" value="向上" onclick="optMove(-1)">
<input type="button" value="向下" onclick="optMove(1)">
</body>
</html>
var str="";
var sel=document.forms[0].sortsele;
for(var i=0;i<sel.options.length;i++){
str+=sel.options[i].value+",";
}
document.forms[0].iHidden.value=str;
发现这个方法实在不错,但有几点不太明白,在页面声明hidden的id为iHidden就可以了吗?这个function是谁提交?在我的action或者servlet里面怎么接收hidden的值?
我没想明白,请大家指正我的代码:
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.util.*"%>
<%@page import="bms.db.ConnDB"%>
<html>
<head>
<title>排序</title>
</head>
<body bgcolor="#ffffff">
<%
String[] myString = {
"a", "b", "c", "d", "e"};
LinkedList list = new LinkedList();
for (int i = 0; i < myString.length; i++) {
list.add(i, myString[i]);
}
%><script language=javascript">
function moveUp()
{
var theObj=document.all.sortsele;
for(var i=1;i<theObj.length;i++)
{
if( theObj.options[i].selected && !theObj.options[i-1].selected )
{
var tempOption=new Option(theObj.options[i-1].text,theObj.options[i-1].value);
theObj.options[i-1].removeNode(true);
theObj.add(tempOption,i);
}
}
}function moveDown()
{
var theObj=document.all.sortsele;
for(var i=theObj.length-2;i>-1;i--)
{
if( theObj.options[i].selected && !theObj.options[i+1].selected )
{
var tempOption=new Option(theObj.options[i].text,theObj.options[i].value);
theObj.options[i].removeNode(true);
theObj.add(tempOption,i+1);
theObj.options[i+1].selected=true;
}
}
}function hidd(){
//不知道是不是这样写,请指出
var str="";
var sel=document.forms[0].sortsele;
for(var i=0;i<sel.options.length;i++){
str+=sel.options[i].value+",";
}
document.forms[0].iHidden.value=str;
}
</script><form name="sortform" method="GET" action="SortAction.do">
<select name="sortsele" size="10" style="WIDTH: 200px" multiple>
<%for (int i = 0; i < list.size(); i++) {%>
<option value="<%=list.get(i)%>"><%=list.get(i)%> </option>
<%}%>
</select>
<input type="hidden" id="iHidden" />
<input type="button" value="上" name="up" onclick="moveUp()"/>
<input type="button" value="下" name="down" onclick="moveDown()"/>
<br/>
<hr/>
<input type="submit" value="提交排序结果"/>
</form>
</body>
</html>
for(i=0;i<document.all['dltSort'].length-1;i++){
document.all['dltSort'].options[i].selected = true;
}
//首先全选这个select,然后提交标单。
function sss()
{
var sel=document.forms[0].sortsele;
if(!sel) return false;
if(sel.length<0)return false;
for(var i=0;i<sel.length;i++)
{
sel.options[i].selected=true;
}
document.forms[0].submit();
}</script>这段代码你没看?