下面我的request.getParameter()如何写!

xietangz 2002-04-03 10:10:22
exportcreate_o.jsp中如何取得下面网页中
form的各项的值?


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK TYPE = "TEXT/CSS" REL = "STYLESHEET" HREF = "sf.css" >
<script language = "JavaScript">
function addrow()
{
newRow = PLList.insertRow(PLList.rows.length);
newRow.id="tdt";
newRow.ln=allCount;

c1 = newRow.insertCell(0);
c1.id="delItem";
c1.ln=allCount;
c1.onclick=delIt;
c1.className="scheduleButtonVisible";
c1.onmouseover=mouseOver;
c1.onmouseout=mouseOut;
c1.innerHTML="<input type='hidden' name='edit'>";
c2 = newRow.insertCell(1);
c2.ln=allCount;
c2.innerHTML="<input type=text name = 'pname' size=20 In= " + allCount + ">";
c3 = newRow.insertCell(2);
c3.ln=allCount;
c3.innerHTML="<input type=text name = 'quantity' size=15 In = " + allCount + ">";
c4 = newRow.insertCell(3);
c4.ln=allCount;
c4.innerHTML="<select name = 'q_unit' In = " + allCount + "><option value='pcs'>pcs</select>";
c5 = newRow.insertCell(4);
c5.ln=allCount;
c5.innerHTML="<input type=text name = 'weight' size=15 In = " + allCount + ">";
c6 = newRow.insertCell(5);
c6.ln=allCount;
c6.innerHTML="<select name = 'w_unit' In = " + allCount + "><option value ='g'>G</select>";
c7 = newRow.insertCell(6);
c7.ln=allCount;
c7.innerHTML="<input type=text name = 'price' size=15 In = " + allCount + ">";
c8 = newRow.insertCell(7);
c8.ln=allCount;
c8.innerHTML="<select name = 'currency' In = " + allCount + "><option value ='rmb'>RMB<option value='us'>US</select>";
allCount++
}


function delIt()
{
line=parseInt(event.srcElement.ln,10)

if (line>0)
for (i=1;i<PLList.rows.length;i++)
if (tdt[i].ln==line)
{
if (document.createbargain.pname[i].value.length>0 || document.createbargain.quantity[i].value.length>0 || document.createbargain.weight[i].value.length>0 || document.createbargain.price[i].value.length>0)
if (!confirm("Are you sure you want to delete this record?"))
return
PLList.deleteRow(i)
}
}

function mouseOver()
{
event.srcElement.className="delMouseOver"
}
function mouseOut()
{
event.srcElement.className="scheduleButtonVisible"
}

</script>


<body bgcolor="#FFFFCC">
<form action = "exportcreate_o.jsp" method = "post" name = "createbargain" >
<p align = center> <b>CIQ BARBAIN EXPORT MANAGER</b></p>
<table cellpadding = "7" width="700" bgcolor="#99CC99" align="center" id="PLList">
<TBODY>
<tr align="center" id = tdt>
<th width = 10>
<div align="center">x
<INPUT name=edit type=hidden>
</div>
</th>
<th width="210">
<div align="center">Product Name
<input name=pname type=hidden>
</div>
</th>
<th width="110">
<div align="center">Permit Quantity
<INPUT name=quantity type=hidden>
</div>
</th>
<th width="50">
<div align="center">Unit_Q
<INPUT name=q_unit type=hidden>
</div>
</th>
<th width="110">
<div align="center">Permit Weight
<INPUT name=weight type=hidden>
</div>
</th>
<th width="50">
<div align="center">Unit_W
<INPUT name=w_unit type=hidden>
</div>
</th>
<th width="110">
<div align="center">Unit_Price(g)
<INPUT name=price type=hidden>
</div>
</th>
<th width="50">
<div align="center">Currency
<INPUT name=currency type=hidden>
</div>
</th>
</tr>
</TBODY>
</table>

<p align = center>
<input type = button name = "add" value = " Add " id="button" OnClick= "addrow()" >
<input type = submit name = "save" value = " Save" id = "buttoon">
</p>
</form>

<SCRIPT>
allCount=1
</SCRIPT>

</body>
</html>
...全文
92 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
weidegong 2002-04-04
  • 打赏
  • 举报
回复
看来你只是用它实现添加的功能了:(
weidegong 2002-04-04
  • 打赏
  • 举报
回复
String strA[]= request.getParameterValues("edit");
for (int i=0;i<strA.length;i++) out.println(strA[i]+"<br>");

shrimp32 2002-04-04
  • 打赏
  • 举报
回复
怎么计算request.getParameterValues("name")取回的数组中字符串的个数?
xietangz 2002-04-03
  • 打赏
  • 举报
回复


我试了很久也没有成功,
书上讲的都一样。

《JSP核心与技术》哪一个出版社出的?
ling_8899 2002-04-03
  • 打赏
  • 举报
回复
我建议你看看《JSP核心与技术》这本书对你肯定收获不少。
好像就是这个书名,我只记得关键字是核心技术。
wes109 2002-04-03
  • 打赏
  • 举报
回复
request.getParameterValues("name");

要多看看书!
ling_8899 2002-04-03
  • 打赏
  • 举报
回复
不好意思,我记错了是《JSP核心技术与电子商务应用实例》,这本书是机械工业出版社出的,挺不错的。
donny2000 2002-04-03
  • 打赏
  • 举报
回复
request.getParameterValues("name");
返回一个数组
xietangz 2002-04-03
  • 打赏
  • 举报
回复

jsp中没有request.form()这个方法。
如何取出动态form中ELEMENTS的数据值呢?

用request.getParameterName(),也不行!!


Hikaru 2002-04-03
  • 打赏
  • 举报
回复
看你的程序是动态追加一行row的,这种情况下,相同域名的域会作为一个数组提交,当然在只有一行的时候不是数组,你需要判断一下。你可以用request.form("item名")之类的方法来取得这个数组,然后取出数据。

81,092

社区成员

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

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