📄 goodschange.jsp
字号:
<%@ page language="java" import="java.util.*,com.test.ps.goods.*"pageEncoding="UTF-8"%>
<%@page import="com.test.ps.util.TransStr;"%>
<%
int cateId=0;
if(request.getParameter("categoryId")!=null)
cateId=Integer.parseInt(request.getParameter("categoryId"));
int parId=0;
if(request.getParameter("parId")!=null)
parId=Integer.parseInt(request.getParameter("parId"));
String goodsCode=request.getParameter("goodsCode");
String action = request.getParameter("action");
Goods initGood=GoodsAction.getGoodsInf(goodsCode);
String initCode=initGood.getGoodsCode();
String initName=initGood.getGoodsName();
String initImg=initGood.getGoodsImage();
float initPrice=initGood.getGoodsPrice();
String initDescr=initGood.getDescr();
String initHot=initGood.getHotgoods();
//处理提交
if(action!=null&& action.trim().equals("submit")){
String goodsName=TransStr.transStr(request.getParameter("goodsName"));
String categoryId=request.getParameter("categoryId");
String goodsImage="image/pic/"+goodsCode+".jpg";
String goodsPrice=request.getParameter("goodsPrice");
String descr=TransStr.transStr(request.getParameter("desc"));
String hotgoods=request.getParameter("onSale");
Date gdate =new Date();
Goods good=new Goods();
good.setGoodsCode(goodsCode);
good.setGoodsName(goodsName);
good.setCategoryId(Integer.parseInt(categoryId));
good.setGoodsImage(goodsImage);
good.setGoodsPrice(Float.valueOf(goodsPrice));
good.setDescr(descr);
good.setHotgoods(hotgoods);
good.setGDate(gdate);
GoodsAction.changeGoods(good,goodsCode);
if(cateId==0)
response.sendRedirect("goodsInf.jsp?goodsCode="+goodsCode);
else
response.sendRedirect("goodsList.jsp?cateId="+cateId+"&parId="+parId);
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<LINK href="../img/adminStyle.css" type=text/css rel=stylesheet>
<script type="text/javascript">
//初始化表单
function init(){
document.all.goodsCode.value="<%=initCode%>";
document.all.goodsName.value="<%=initName%>";
document.all.goodsPrice.value=<%=initPrice%>;
//document.all.desc.value="<%//=initDescr%>";
if("<%=initHot%>"=="1")
document.all.isHot.checked=true;
else
document.all.notHot.checked=true;
}
//检查商品名格式
function checkName(o)
{
var errName=document.getElementById("errName");
var check=/^([^u4E00-u9FA5]|[a-zA-Z0-9]){1}+([^u4E00-u9FA5]|[a-zA-Z0-9]|[._-]){5,29}$/;
if(o.value==""){
errName.innerHTML="* <span style=\"color:#FF0000\">商品名不能为空</span>";
document.all.submitToAdd.disabled=true;
}
else if(!check.exec(o.value)){
errName.innerHTML="* <span style=\"color:#FF0000\">商品名必须为6-30位的字母、数字或中文</span>";
document.all.submitToAdd.disabled=true;
}
else{
errName.innerHTML="*";
document.all.isNameRight.value="right";
if(document.all.isPriceRight.value=="right")
document.all.submitToAdd.disabled=false;
}
}
//检查价格格式
function checkPrice(o)
{
var errPrice=document.getElementById("errPrice");
var check=/^(([1-9][0-9]{0,17})|0)$/;
if(o.value==""){
errPrice.innerHTML="* <span style=\"color:#FF0000\">商品价格不能为空</span>";
document.all.submitToAdd.disabled=true;
}
else if(!check.exec(o.value)){
errPrice.innerHTML="* <span style=\"color:#FF0000\">请输入18位以下数字</span>";
document.all.submitToAdd.disabled=true;
}
else{
errPrice.innerHTML="*";
document.all.isPriceRight.value="right";
if(document.all.isNameRight.value=="right")
document.all.submitToAdd.disabled=false;
}
}
//弹出上传图片窗口
function uploadPic(){
window.open("uploadPic.jsp?goodsCode="+document.all.goodsCode.value,"上传图片",
"height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,status=no,location=no,dependent=yes,hotkeys=yes,left=400,top=200,z-look=yes");
}
</script>
<style type="text/css">
<!--
.STYLE2 {font-weight: bold}
-->
</style>
</head>
<body onLoad="init()">
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="80" colspan="3">
<jsp:include page="../adminTop.jsp" flush="true"/></td>
</tr>
<tr>
<td colspan="3" height="30" bgcolor="#e6f3ff"><span class="STYLE2 STYLE2"><a href="../adminRight.jsp">首页</a>><a href="javascript:history.go(-1)">商品列表</a>>修改商品</span></td>
</tr>
<tr>
<td colspan="3" height="30"><hr size="5" color="#e6f3ff" /></td>
</tr>
<tr>
<td height="30"><h1>请填写商品信息</h1></td>
</tr>
<tr>
<td height="30" valign="top">
<form action="" method="post" name="goodsAdd" id="goodsAdd">
<table width="677" height="360" border="0" align="left" cellpadding="0" cellspacing="0">
<input type="hidden" name="isNameRight" value="right" />
<input type="hidden" name="categoryId" value="<%=cateId%>" />
<input type="hidden" name="action" value="submit" />
<input type="hidden" name="isPriceRight" value="right" />
<tr>
<td width="73" rowspan="7"> </td>
<td width="75"><div align="center">商品编号</div></td>
<td colspan="2"><label>
<input type="text" name="goodsCode" size="25" disabled="disabled" />
</label></td>
<td width="350"><div id="errCode">*</div></td>
</tr>
<tr>
<td><div align="center">名称</div></td>
<td colspan="2"><label>
<input type="text" name="goodsName" size="25" onBlur="checkName(this)" />
</label></td>
<td><div id="errName">*</div></td>
</tr>
<tr>
<td><div align="center">图片</div></td>
<td colspan="3"><input type="button" name="upLoadImg" value="点击上传图片" onClick="uploadPic()"/> <a href="javascript:window.location='/img/<%=goodsCode%>.jpg';"></a></td>
</tr>
<tr>
<td><div align="center">价格</div></td>
<td colspan="2"><label>
<input type="text" name="goodsPrice" size="25" onBlur="checkPrice(this)" />
</label></td>
<td><div id="errPrice">*</div></td>
</tr>
<tr>
<td valign="top" height="120"><div align="center">详细描述</div></td>
<td colspan="3" valign="top"><label>
<textarea name="desc" rows="12" cols="30"><%=initDescr %></textarea>
</label></td>
</tr>
<tr>
<td><div align="center">是否热卖</div></td>
<td width="68"><label>
<input type="radio" id="isHot" name="onSale" value="1" />是 </label></td>
<td width="111"><label>
<input type="radio" id="notHot" name="onSale" value="0" checked="checked" />否</label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submitToAdd" value="确认修改" disabled="disabled" /></td>
<td colspan="2"> </td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td><hr align="left" size="10" noshade color="#318EB7"></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -