📄 viewitem.jsp
字号:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>viewItem.jsp</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<script>
//这个功能用来检查输入是否为空,并且算出折扣后的价格
function check(){
document.f1.sumprice.disabled = "disabled";
document.f1.discount.disabled = true;
document.f1.number.disabled = true;
document.f1.promoteprice.disabled = true;
//货物数量名称单价不能为空
if(document.f1.name.value==""){
alert("请输入货物名称");
}else if(document.f1.num.value==""){
alert("请输入货物数量");
}else if(document.f1.price.value==""){
alert("请输入货物单价");
}
//算出折扣号
if(document.f1.select.value=="0")
document.f1.sumprice.value=parseInt(document.f1.num.value)*parseFloat(document.f1.price.value);
else if(document.f1.select.value=="1"){
document.f1.discount.disabled = false;
if(document.f1.discount.value==""){
alert("请输入折扣率");
}else if(document.f1.discount.value >1 ||document.f1.discount.value<=0){
alert("请输入0-1之间的折扣率");
}
{
document.f1.sumprice.value=parseInt(document.f1.num.value)*parseFloat(document.f1.price.value)*parseFloat(document.f1.discount.value);
}
}else{
document.f1.number.disabled = false;
document.f1.promoteprice.disabled = false;
document.f1.discount.disabled = true;
if(document.f1.number.value=="")
alert("请输入促销数量");
else if(parseInt(document.f1.number.value)>parseInt(document.f1.num.value))
alert("促销数量大于总数目了!");
else if(document.f1.promoteprice.value=="")
alert("请输入促销价格");
else{
document.f1.sumprice.value=(parseInt(document.f1.num.value)-parseInt(document.f1.number.value))*parseFloat(document.f1.price.value)+parseInt(document.f1.number.value)*parseFloat(document.f1.promoteprice.value)
}
}
if(isNaN(document.f1.sumprice.value)){
alert("请输入整数!");
}
}
</script>
<%!//这个类用来显示折扣
public String ifSelect(String s, String discountType) {
if (s.equals(discountType))
return "selected";
else {
return "";
}
}%>
<%
//将数据从sevlet中取出显示
String selected = "selected";
String orderId = (String) session.getAttribute("orderId");
String itemId = (String) session.getAttribute("itemId");
String name = (String) session.getAttribute("name");
String discountType = String.valueOf(session.getAttribute("discountType"));
String num = String.valueOf(session.getAttribute("num"));
String price = String.valueOf(session.getAttribute("price"));
String sum = String.valueOf(session.getAttribute("sum"));
String discount = String.valueOf(session.getAttribute("discount"));
String promotionNum = String.valueOf(session
.getAttribute("promotionNum"));
String promotionPrice = String.valueOf(session
.getAttribute("promotionPrice"));
%>
<body vlink="red">
<form name="f1" method="post" action="/Order/servlet/UpdateItem">
<a href="/Order/servlet/SearchAll">返回订单列表<a>-><a
href="/Order/servlet/ViewOrder">返回订单详情页面<a>->添加订单明细:<br>
<table border="1">
<tr>
<td colspan="2" align="center">
当前订单号
<%=orderId%>
<input type="hidden" name="orderId" value=<%=orderId%>>
<input type="hidden" name="itemId" value=<%=itemId%>>
</td>
</tr>
<tr>
<td align="center">
货物名称
<input type="text" name="name" value=<%=name%>>
</td>
<td align="center">
折扣类型
<select name="select" value=<%=discountType%> onBlur=check()>
<option value="0" <%=ifSelect("0", discountType)%>>
无折扣
</option>
<option value="1" <%=ifSelect("1", discountType)%>>
有折扣
</option>
<option value="2" <%=ifSelect("2", discountType)%>>
有促销
</option>
</select>
</td>
</tr>
<tr>
<td align="center">
货物数量
<input type="text" name="num" value=<%=num%> onBlur=check()>
</td>
<td align="center">
货物单价
<input type="text" name="price" value=<%=price%>
onBlur=check()>
</td>
</tr>
<tr>
<td align="center">
货物总价
<input type="text" name="sumprice" value=<%=sum%>
onBlur=check()>
</td>
<td align="center">
折扣率
<input type="text" name="discount" value=<%=discount%>
onBlur=check()>
</td>
</tr>
<tr>
<td align="center">
促销数量
<input type="text" name="number" value=<%=promotionNum%>
onBlur=check()>
</td>
<td align="center">
促销单价
<input type="text" name="promoteprice"
value=<%=promotionPrice%> onBlur=check()>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="sub" value="确认">
</td>
<td valign="top">
<br>
</td>
</tr>
</table>
</form>
</body>
<script>
</script>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -