高手请进!请问怎样将多选框中"选中的多项内容"获取?

weiqingal 2005-01-15 06:05:25
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>start</title>
<LINK rel="stylesheet" href="../../css/main.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body MS_POSITIONING="GridLayout">
<FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT>
<BR>
<BR>
<form id="Form1" method="post" action="do.asp">
<table align="center">
<tr align=center>
<td width=160><select size=10 name="list1" style="width:120">
<option value=1>1111111</option>
<option value=2>2222222</option>
<option value=3>3333333</option>
<option value=4>4444444</option>
<option value=5>5555555</option>
<option value=6>6666666</option>
<option value=7>7777777</option>
</select></td>
<td><input type="button" value="增 加>>>" onclick="add()">
<br/>
<br/>
<input type="button" value="<<<删 除" onclick="del()">
</td>
<td width=79><select name="seqItem" id="seqItem" size="10" style="width:120">
</select></td>
<td width=79>

</td>
</tr>
</table>
<div align="center">
<input type="button" value="重 置" onClick="doRe()">
<input type="submit" name="ok" value="提 交">
</div>
</form>
<SCRIPT LANGUAGE="javascript">
var seqSelect=document.forms[0].seqItem;
var length=5;


function doRe(){
document.forms[0].action="";
document.forms[0].submit();
}

function setCursor(objStyle,cursor)
{
objStyle.cursor = cursor;
}
<!--
function goClick()
{

var res ="";
for (var i =0;i<seqSelect.options.length;i++)
{
if(seqSelect.options[i].selected)
{
res += seqSelect.options[i].index +",";
}
}

alert(res);
}
//-->
function add_singer(object,value,text)//添加数据
{
if(singer_exist(object,value)==false)
{
object.options.add(new Option(text,value,true,true));
return true;
}
return false;
}
function remove_singer(object,index)//删除数据
{
if(index<0)return false;
object.options.remove(index)
}
function singer_exist(object,value)//检查是否存在
{
for(var i=0;i<object.options.length; i++)
{
if(object.options[i].value==value)
return true;
}
return false;
}
function add()
{
var obj1=document.all.list1;
var index=obj1.selectedIndex;
if (index<0) return false;
value=obj1.options[index].value;
text=obj1.options[index].text;
var obj2=document.all.seqItem;
add_singer(obj2,value,text)
remove_singer(obj1,index)
}
function del()
{
var obj2=document.all.seqItem;
var index=obj2.selectedIndex;
if (index<0) return false;
value=obj2.options[index].value;
text=obj2.options[index].text;
var obj1=document.all.list1;
add_singer(obj1,value,text)
remove_singer(obj2,index)
}
</script>
</body>
</html>

效果就是将选中的多项内容获取?
...全文
534 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
weiqingal 2005-01-19
  • 打赏
  • 举报
回复
谢谢 wen1818(冷月孤心)!
whghwujx 2005-01-17
  • 打赏
  • 举报
回复
选了多少个就有多少个元素
whghwujx 2005-01-17
  • 打赏
  • 举报
回复
request.form()取得的数值是一个一维的数组,各个元素之间用逗号隔开
5207 2005-01-17
  • 打赏
  • 举报
回复
SPRIT
jarraytan 2005-01-16
  • 打赏
  • 举报
回复
谢谢 simaqingfeng(司马青枫)大哥解答,小弟拜谢了!
clcy 2005-01-16
  • 打赏
  • 举报
回复
获取多个值???

in ("&request("id")&")"
simaqingfeng 2005-01-16
  • 打赏
  • 举报
回复
是一个数组
jarraytan 2005-01-15
  • 打赏
  • 举报
回复
有了multiple后可以多选,但用request()接收时是什么情况呢?是一个数组吗???请教了。。。
mqjshanghai 2005-01-15
  • 打赏
  • 举报
回复
<select name="seqItem" id="seqItem" multiple size="10" style="width:120">
EEE555 2005-01-15
  • 打赏
  • 举报
回复
如果在asp中是这样的,当然特效中不一样
dim aaa
aaa=request("seqItem")
if aaa="1" then '当接收为1时
...这里写上是1111111怎么处理....
end if
if aaa="2" then
...这里写上是2222222怎么处理....
end if
以下类推...

wen1818 2005-01-15
  • 打赏
  • 举报
回复
你之所以用request("seqItem")只能获取一个,是因为少了multiple

<select name="seqItem" id="seqItem" multiple size="10" style="width:120">
wen1818 2005-01-15
  • 打赏
  • 举报
回复
这样就可以了
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>start</title>
<LINK rel="stylesheet" href="../../css/main.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body MS_POSITIONING="GridLayout">
<FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT>
<BR>
<BR>
<form id="Form1" method="post" action="do.asp">
<table align="center">
<tr align=center>
<td width=160><select size=10 name="list1" style="width:120">
<option value=1>1111111</option>
<option value=2>2222222</option>
<option value=3>3333333</option>
<option value=4>4444444</option>
<option value=5>5555555</option>
<option value=6>6666666</option>
<option value=7>7777777</option>
</select></td>
<td><input type="button" value="增 加>>>" onclick="add()">
<br/>
<br/>
<input type="button" value="<<<删 除" onclick="del()">
</td>
<td width=79><select name="seqItem" id="seqItem" size="10" style="width:120" multiple>
</select></td>
<td width=79>

</td>
</tr>
</table>
<div align="center">
<input type="button" value="重 置" onClick="doRe()">
<input type="button" name="ok" value="提 交" onClick="goClick()">
</div>
</form>
<SCRIPT LANGUAGE="javascript">
var seqSelect=document.forms[0].seqItem;
//var length=5;


function doRe(){

document.forms[0].action="";
document.forms[0].submit();

}

function setCursor(objStyle,cursor)
{
objStyle.cursor = cursor;
}

function goClick()
{
var res=""
{for(var i=0;i<seqSelect.options.length;i++ )
res=res+","+seqSelect.options[i].value
}
alert(res);
}

function add_singer(object,value,text)//添加数据
{
if(singer_exist(object,value)==false)
{
object.options.add(new Option(text,value,true,true));
return true;
}
return false;
}
function remove_singer(object,index)//删除数据
{
if(index<0)return false;
object.options.remove(index)
}
function singer_exist(object,value)//检查是否存在
{
for(var i=0;i<object.options.length; i++)
{
if(object.options[i].value==value)
return true;
}
return false;
}
function add()
{
var obj1=document.all.list1;
var index=obj1.selectedIndex;
if (index<0) return false;
value=obj1.options[index].value;
text=obj1.options[index].text;
var obj2=document.all.seqItem;
add_singer(obj2,value,text)
remove_singer(obj1,index)
}
function del()
{
var obj2=document.all.seqItem;
var index=obj2.selectedIndex;
if (index<0) return false;
value=obj2.options[index].value;
text=obj2.options[index].text;
var obj1=document.all.list1;
add_singer(obj1,value,text)
remove_singer(obj2,index)
}
</script>
</body>
</html>
scoutlin 2005-01-15
  • 打赏
  • 举报
回复
:<select name="seqItem" id="seqItem" multiple size="10" style="width:120">
gu1dai 2005-01-15
  • 打赏
  • 举报
回复
楼主还是首先想想有没别的解决办法吧
suhongwei 2005-01-15
  • 打赏
  • 举报
回复
你记用户全选所有的选项那么你的服务器端就可以得到所有的选项的值

当然这是不可行的?

问题是你的需求为什么是这样的?
weiqingal 2005-01-15
  • 打赏
  • 举报
回复
怎样才能把选项:<select name="seqItem" id="seqItem" size="10" style="width:120">
中"seqItem选中的内容都获取?冥思苦想郁闷半天?
我用request("seqItem")只能获取一个?
我相信一定有人可以?

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧