我想实现的功能是:
在A.jsp页面中有一个表格,当点击A页面中的一个按钮时,会弹出B.jsp页面,B页面中是一个list,每行数据前有一个chechbox,当提交B页面时,checkbox钩上的数据会自动在A页面的表格中显示,并且A页面中可以重复打开B页面,要去掉重复值.
这个用FORM怎么实现?
在A.jsp页面中有一个表格,当点击A页面中的一个按钮时,会弹出B.jsp页面,B页面中是一个list,每行数据前有一个chechbox,当提交B页面时,checkbox钩上的数据会自动在A页面的表格中显示,并且A页面中可以重复打开B页面,要去掉重复值.
这个用FORM怎么实现?
A.jsp如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<div style="height:230px;width:99.9%;overflow:auto;"><table nowrap id="CommidityGrid" border="0" cellspacing="1" cellpadding="0" BGCOLOR="#949293" width="100%">
<Div>
<Script Language="javascript">
function GridSelectTree(row)
{
var temp=0;
var fruit="";
for(var i=0; i<Form1.rownum.value;i++)
{
if (document.all("PyOrdNum" + i)!=null)
if (document.all("PyOrdNum" + i).value!="")
{
temp++;
if(temp==1)
{
fruit= document.all("PyOrdNum" + i).value;}
else
{
fruit= fruit+","+document.all("PyOrdNum" + i).value;
}
}
}
window.open('../SysSelect/B.jsp?PageNo=1'+'&nInputGridCurRow='+row+'&fruit='+fruit+'&RowNum='+RowNum,'','resizeable=no,menubar=no,scrollbars=yes,width=700,height=500,left=190+'+(screen.availWidth-700)/2+' ,top='+(screen.availHeight-500)/2) ;
} </Script>
</Div>
<tr class="ListTableHeader1" align="center" height="20px" bgcolor="#FFFFFF">
<td width="10%">货品编号</td>
<td width="15%">货品名称</td>
<td width="15%">产地</td>
<td width="10%">货品规格</td>
<td width="9%">单位</td>
<td width="10%">单价</td>
<td width="8%">数量</td>
<td width="10%">总价</td>
<td width="10%">折合包装</td>
<td width="3%"> </td>
<td style="display:none"></td>
<td style="display:none"></td>
</tr><%for(int i=1;i<=10;i++){%>
<tr bgColor="#FFFFFF" ID="GridRow<%=i %>">
<td><input type="text" style="width:100%" name="PyOrdNum<%=i%>" class="ClientTableflateditbox" onFocus="this.style.background='#90EE90'" onkeydown=" " onBlur="this.style.background='#FFFFFF';" onclick="GridSelectTree('<%=i%>');" ></td>
<td><input type="text" style="width:100%" name="PyOrdName<%=i%>" class="ClientTableflateditbox" onFocus="this.style.background='#90EE90'" onkeydown=" " onBlur="this.style.background='#FFFFFF';" onclick="GridSelectTree('<%=i%>')" ></td>
<td><input type="text" style="width:100%" name="PyOrdAd<%=i%>" class="ClientTableflateditbox" onFocus="this.style.background='#90EE90'" onBlur="this.style.background='#FFFFFF';" onclick="GridSelectTree('<%=i%>')" ></td>
<td><input type="text" style="width:100%" name="PyOrdGg<%=i%>" class="ClientTableflateditbox" onFocus="this.style.background='#90EE90'" onBlur="this.style.background='#FFFFFF';" onclick="GridSelectTree('<%=i%>')" ></td>
<td align="center"><select size="1" name="PyOrdDw<%=i%>" style="width:80px;font-size:12px" >
<option value="" > </option>
</select></td>
<td><input type="text" style="width:100%" name="PyOrdPrice<%=i%>" class="ClientTableflateditbox" onFocus="this.style.background='#90EE90'" onKeyPress="return(currencyFormat(this,',','.',event));">
<input type="hidden" name="h_ysPrice<%=i%>">
</td>
<td><input type="text" style="width:100%" name="PyOrdCount<%=i%>" class="ClientTableflateditbox" onFocus="this.style.background='#90EE90'" onchange="javascript:zhjs('<%=i%>');SPrice('<%=i%>');">
<input type="hidden" name="h_ysCount<%=i%>">
</td>
<td><input type="text" style="width:100%" name="PyOrdSPrice<%=i%>" class="ClientTableflateditbox" onFocus="this.style.background='#90EE90'" onBlur="this.style.background='#FFFFFF';" readonly=""></td>
<td><input type="text" style="width:100%" name="PyOrdZh<%=i%>" class="ClientTableflateditbox" onFocus="this.style.background='#90EE90'" onBlur="this.style.background='#FFFFFF';" readonly=""></td>
<td align="center"><img src="../images/ndelete.gif" width="16" height="16" style="cursor:hand" onmouseover="this.src='../images/hdelete.gif'" onmouseout="this.src='../images/ndelete.gif'" onclick="DeleteRow('<%=i%>')" ></td>
<td style="display:none"><input type="hidden" name="CommidityTypeID<%=i%>"></td>
</tr>
<%}%>
</table>
<br> </div>
B.jsp如下:<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<%@ page import="java.util.*"%><jsp:useBean id="nongzi" scope="request" class="beartool.Sys_GoodsFunction"/>
<jsp:useBean id="nongzi4" scope="request" class="beartool.Sales_Billing_Function"/>
<%
//nPageViewLimit = LIMIT_CRMCommodityForSelectView
//nPageOperateLimit = LIMIT_CRMCommodityOper
nAddButtonStyle = 1;
nPageSize = 35;
%>
<%@ include file="../System/PowerList.jsp"%>
<%
int m=0;
int n=0;
String S="";
String AA[][];//货品资料的获取
String BB[][];//获取单位单价信息
String CC[][];//货品所有单位的读取
AA=nongzi.GetSysGoods1(DBName,sysid);String fruit=request.getParameter("fruit");//第一次进页面
String nInputGridCurRow=request.getParameter("nInputGridCurRow");//第一次进页面
int Row=Integer.parseInt(nInputGridCurRow);
String Num=request.getParameter("RowNum");//第一次进页面
int RowNum=Integer.parseInt(Num);
String GOID_2=request.getParameter("GOID_2");//货品编号
String GONAME_2=codeToString(request.getParameter("GONAME_2"));//货品名称
String CX=request.getParameter("cx");//业务员编号
String GOTYPEID=(String)request.getParameter("GOTYPEID");
szPageBarURL="SelectGoodsTwo.jsp?nInputGridCurRow="+nInputGridCurRow+"&fruit="+fruit+"&RowNum="+Num+"&PageNo=";
AA=nongzi4.GetSysGoods2(DBName,sysid,GOID_2,GOTYPEID);
%>
<head>
<title>货品资料</title><script language="javascript">
var BB1 = new Array() ;
var BB2 = new Array() ;
var BB3 = new Array() ;
var BB4 = new Array() ;
var BB5 = new Array() ;
var BB6 = new Array() ;
</script>
<script LANGUAGE="javascript">function setButton(){
document.all.ButtonSelect.disabled = false ;
}
function setButton2(){ document.all.ButtonSelect.disabled = true;
}
function selectOK(m){
var row="<%=Row%>";
var row2="<%=RowNum%>";
var temp=0;
var start ="<%=fruit%>";
var t=0;
var s1=new Array();
s1=start.split(",");
var kaishi=document.Form1.kaishi.value;
var jieshu= document.Form1.jieshu.value;
for(var i=kaishi; i<=jieshu;i++)
{
if(document.all("chkbox"+i).checked == true)
{
t=0;
for(var x=0;x<s1.length;x++)
{
var ss=s1[x];
if(BB1[i]==ss)
{
t=1;}
}
if(t==1)
{
}
else
{ if(row>=row2)
{opener.insertRow2();}
opener.document.all["PyOrdNum"+row].value=BB1[i] ;//编号
opener.document.all["PyOrdName"+row].value=BB2[i];//货品名称
opener.document.all["PyOrdAd"+row].value=BB3[i] ;//地址
opener.document.all["PyOrdGg"+row].value=BB4[i] ;//规格
opener.document.all["PyOrdPrice"+row].value=setCurrency(BB6[i]);//进价
opener.document.all["h_ysPrice"+row].value=BB6[i];//原始进价
var s2 = new Array() ;
s2=BB5[i].split(",");
var shi=opener.document.Form1.all["PyOrdDw"+row];//货品所有单位
//var shi=opener.document.Form1.Price_Edit1;
for(var mm=shi.options.length;mm>=0;mm--)
{ shi.options[mm]=null;//将该项设置为空,也就等于清除了
//shi.remove(0);
}
shi.length = s2.length;
for(var j=0;j<s2.length;j++){//这个循环是填充下拉列表
//shi.options[n]=new Option(s1[j],s1[j])
shi.options[j].text = s2[j];
shi.options[j].value = s2[j];
}
temp++;
row++;
}
}//if
}//for(var i=0; i<m ; i++)
if(temp==0&&BB1[nCurrentRow+1]==null)
{alert("请选择货品!");}
else
{if(temp!=0)
{
window.close() ;
}
else
{ //用于判断所选客户是否重复
var start ="<%=fruit%>";
var t=0;
var s1=new Array();
s1=start.split(",");
for(var i=0;i<s1.length;i++)
{
var ss=s1[i];
if(BB1[nCurrentRow+1]==ss)
{
t=1;}
}
if(t==1)
{alert("该货品已经选择不可重复!");
}
else
{
if(row>=row2)
{opener.insertRow2();}
opener.document.all["PyOrdNum"+row].value=BB1[nCurrentRow+1] ;//编号
opener.document.all["PyOrdName"+row].value=BB2[nCurrentRow+1];//货品名称
opener.document.all["PyOrdAd"+row].value=BB3[nCurrentRow+1] ;//地址
opener.document.all["PyOrdGg"+row].value=BB4[nCurrentRow+1] ;//规格
opener.document.all["PyOrdPrice"+row].value=setCurrency(BB6[nCurrentRow+1]);//进价
opener.document.all["h_ysPrice"+row].value=BB6[nCurrentRow+1];//原始进价
var s3 = new Array() ;
s3=BB5[nCurrentRow+1].split(",");
var shi=opener.document.Form1.all["PyOrdDw"+row];//货品所有单位
//var shi=opener.document.Form1.Price_Edit1;
for(var mm=shi.options.length;mm>=0;mm--)
{ shi.options[mm]=null;//将该项设置为空,也就等于清除了
//shi.remove(0);
}
shi.length = s3.length;
for(var j=0;j<s3.length;j++){//这个循环是填充下拉列表
//shi.options[n]=new Option(s1[j],s1[j])
shi.options[j].text = s3[j];
shi.options[j].value = s3[j];
}
window.close() ;
}
}
}
} </script></head>
<body <%=BODY%>>
<form method="post" action="" name="Form1">
<table width="100%" height="100%" >
<tr>
<td valign="top">
<table <%=TABLE_LIST_FORMAT %>>
<tr class="ListTableHeader">
<td align="center" ><input type="checkbox" name="checkboxall" value="" onClick="javascript:selectAllture();"/></td>
<td nowrap align="center" >编号</td>
<td nowrap align="center" >货品名称</td>
<td nowrap align="center" >产地</td>
<td nowrap align="center" >货品规格</td>
<td nowrap align="center" >单位</td>
<td nowrap align="center" >单价</td>
</tr>
<%if(AA.length==0)
{%>
<tr class="ListTableRow">
<td colspan="7" align="center"> 没有数据!</td>
</tr>
<%}else{%>
<%
nRecordCount=0;
nStartLine = nPageSize * (nPageNo - 1);
nEndLine = nPageSize * nPageNo - 1;
nRecordCount=AA.length;
int kaishi=(int)nStartLine;
int jieshu=(int)nEndLine;
n=0;
while((nStartLine+n++)<=nEndLine){
m=(int)nStartLine+n-1;
if(m<AA.length){
%><tr class="ListTableRow" id="Row" onClick="javascript:setRowFocus(this,false,<%=(m - 1)%>);setButton()" onDblClick="javascript:selectOK('<%=AA.length%>');">
<td align="center"><input name="chk" type="checkbox" id="chkbox<%=m%>" value="<%=AA[m][1]%>" onClick="javascript:selectture('<%=m%>');"></td>
<% BB=nongzi.GetSysGoodHSUnit(DBName,sysid,AA[m][0],"1");%>
<td nowrap align="center"><%=AA[m][0]%></td>
<td nowrap align="center"><%=AA[m][1]%></td>
<td nowrap align="center"><%=AA[m][4]%></td>
<td nowrap align="center"><%=AA[m][14]%></td>
<td nowrap align="center"><%=BB[0][1]%></td>
<td nowrap align="center"><%=BB[0][3]%></td>
<%
S="";
CC=nongzi.GetSysGoodHSUnit2(DBName,sysid,AA[m][0]);
int i=0;
while(i<CC.length)
{ if(i==(CC.length-1))
{S=S+CC[i][1];}
else
{S=S+CC[i][1]+",";}
i++;}
%>
</tr>
<script LANGUAGE="javascript">
<!--
BB1[<%=m%>] = '<%=AA[m][0]%>' ;
BB2[<%=m%>] = '<%=AA[m][1]%>' ;
BB3[<%=m%>] = '<%=AA[m][4]%>' ;
BB4[<%=m%>] = '<%=AA[m][14]%>' ;
BB5[<%=m%>] = '<%=S%>' ;
BB6[<%=m%>] = '<%=BB[0][3]%>' ;
//-->
</script>
<%}}if(jieshu>AA.length-1)
{jieshu=AA.length-1;}%>
<input type="hidden" name="kaishi" value="<%=kaishi%>" >
<input type="hidden" name="jieshu" value="<%=jieshu%>" >
<%}%>
</table>
<%@ include file="../System/MainPageBar2.jsp"%>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td valign="bottom" align="center">
<input type="Button" name="ButtonSelect" value=" 选 择 " class="ButtonClass" onClick="javascript:selectOK('<%=AA.length%>');" disabled>
<input type="Button" name="ButtonReturn" value=" 返 回 " class="ButtonClass" onClick="window.close() ;">
</td>
</tr>
<tr>
<td height="8"></td>
</tr>
</table>
<script language="javascript">
function selectAllture()
{//复选框全选
try{
var start ="<%=m%>";
var kaishi=document.Form1.kaishi.value;
var jieshu= document.Form1.jieshu.value;
if (document.all("checkboxall").checked == true)
{ setButton()
for (var i =kaishi;i<=jieshu;i++)
{
document.all("chkbox"+i).checked=true;
}
}
else
{setButton()
for (var i =kaishi;i<=jieshu;i++)
{
document.all("chkbox"+i).checked=false;
}
}
}
catch(e){
}
}
function selectture(m)
{//复选框选中(判断客户是否重复)
try{
var start ="<%=fruit%>";
var t=0;
if (document.all("chkbox"+m).checked == true)
{
var s1=new Array();
s1=start.split(",");
for(var i=0;i<s1.length;i++)
{
var ss=s1[i];
if(BB1[m]==ss)
{
t=1;}
}
if(t==1)
{alert("该人员已经选择不可重复!");
document.all("chkbox"+m).checked =false}
}
}
catch(e){
}
}</script>
</form>
</body>
</html>