实现电影订票,用户输入电话号码,选择电影场次及电影票张数,系统进行价格结算的 JSP 代码
时间: 2023-03-01 15:38:52 浏览: 129
JSP基于SSH2电影订票管理系统+源代码+文档说明+数据库.zip
以下是一种实现电影订票的 JSP 代码示例:
```
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>电影订票系统</title>
</head>
<body>
<h1>电影订票系统</h1>
<form action="submitOrder.jsp" method="post">
<p>电话号码:<input type="text" name="phoneNumber"></p>
<p>选择电影场次:
<select name="movieSession">
<option value="1">电影1 10:00场</option>
<option value="2">电影2 12:00场</option>
<option value="3">电影3 14:00场</option>
<option value="4">电影4 16:00场</option>
</select>
</p>
<p>电影票张数:<input type="text" name="ticketCount"></p>
<input type="submit" value="提交">
</form>
</body>
</html>
```
在submitOrder.jsp中,可以实现价格结算:
```
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>电影订票系统</title>
</head>
<body>
<h1>电影订票系统</h1>
<%
String phoneNumber = request.getParameter("phoneNumber");
String movieSession = request.getParameter("movieSession");
String ticketCountStr = request.getParameter("ticketCount");
int ticketCount = Integer.parseInt(ticketCountStr);
double price = 0.0;
if (movieSession.equals("1")) {
price = ticketCount * 30;
} else if (movieSession.equals("2")) {
price = ticketCount * 40;
} else if (movieSession.equals("3")) {
price = ticketCount * 50;
} else if (movieSession.equals("4")) {
price = ticketCount * 60;
}
%
阅读全文