怎么得到表单中提交的list表单项的所有元素

tomatowitch 2002-12-10 08:26:47
我在提交list的时候,只能得到list表单项中被选种的那个元素的值
不知道用什么方法能得到所有的元素
...全文
211 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tomatowitch 2002-12-23
  • 打赏
  • 举报
回复

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<jsp:useBean id="show" scope="page" class="com.tomato.forumDB.forumDB"/>
<html>
<head>
<title>顶级栏目次序调整</title>
<SCRIPT language=javascript>
function mysubmit(form)
{
with(form){
selectValue.value=''
for(i=1;i<s1.length;i++)
selectValue.value+=s1.options[i].value+','
}
}
function moveUp(obj)
{
with (obj){
if(selectedIndex==1){
options[length]=new Option(options[1].text,options[1].value)
options[1]=null
selectedIndex=length-1
}
else if(selectedIndex>1) moveG(obj,-1)
}
}
function moveDown(obj)
{
with (obj){
if(selectedIndex==length-1){
var otext=options[selectedIndex].text
var ovalue=options[selectedIndex].value
for(i=selectedIndex; i>1; i--){
options[i].text=options[i-1].text
options[i].value=options[i-1].value
}
options[i].text=otext
options[i].value=ovalue
selectedIndex=1
}
else if(selectedIndex>0 && selectedIndex<length-1) moveG(obj,+1)
}
}
function moveG(obj,offset)
{
with (obj){
desIndex=selectedIndex+offset
var otext=options[desIndex].text
var ovalue=options[desIndex].value
options[desIndex].text=options[selectedIndex].text
options[desIndex].value=options[selectedIndex].value
options[selectedIndex].text=otext
options[selectedIndex].value=ovalue
selectedIndex=desIndex
}
}
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel=stylesheet href="styles.css" type=text/css>
</head>

<body bgcolor="#FFFFFF" text="#000000" topmargin="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td bgcolor="#F7F7F7">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="txt">
<tr>
<td height="19">顶级栏目管理 </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="15">
<form method="post" name=shezhi onsubmit=mysubmit(this) action="/servlet/com.tomato.servlets.subject.getNewOrder">
<table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#33CCFF">
<tr>
<td width="30%" bgcolor="#E8F8FF">
<div align="center">
<select name="s1" size="9">
<option value="-1">-----------------</option>
<%
ResultSet rs=show.executeQuery("select * from class order by orderby");
while(rs.next())
{
%>
<option value="<%=rs.getString("ztid")%>"><%=rs.getString("class")%></option>
<%
}
show.destroy();
%>
</select>
</div>
</td>
<td width="70%" bgcolor="#E8F8FF">
<input type="button" onclick=moveUp(this.form.s1) value="∧">
<input name=selectValue type=hidden value=with(this)>
<input
name=netColumnid type=hidden value=15>
<input name=netMagazineid
type=hidden value=1>
<input name=totalNum type=hidden value=1>
<br>
<br>
<input type="button" onclick=moveDown(this.form.s1) value="∨">
<br>
<br>
<input type="submit" name="Submit" value="保存">
<br>
<br>
<input type="button" value="关闭窗口" onclick="window.close();">
</td>
</tr>
</table>
</form>
</td>
</tr>

</table>
</body>
</html>

以上是我的程序,我自己来结了吧
zhx_232 2002-12-10
  • 打赏
  • 举报
回复
java.util.Enumeration mystr=request.getParameterNames();
int i;
try{
while(mystr.hasMoreElements()){
String e=mystr.nextElement().toString();
if(e.indexOf("group")==-1) {
String[] add=request.getParameterValues(e);
for(i=0;i<address.length;i++) myaddr.addaddr(add[i]);
}
}
}catch(Exception e){
System.err.println(e.getMessage());
}

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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