dictionary_cityadd.jsp
来自「java开发的办公系统 1.系统管理 (地区管理,部门管理,菜单管理,用户管理」· JSP 代码 · 共 227 行
JSP
227 行
<%@ include file="../../include/configuration.jsp"%>
<%@ include file="../../include/authorizemanager.jsp"%>
<%@ page import="com.vere.dictionary.bean.*"%>
<%@ page import="com.vere.dictionary.item.*"%>
<%@ page import="com.vere.dictionary.xml.*"%>
<%@ page contentType="text/html; charset=gb2312" %>
<%
SessionFactory sessionFactory=(SessionFactory)session.getAttribute("sessionFactory");
ParameterUtils.setCharacterEncoding(request);
String status=ParameterUtils.getString(request,"status");
String message="";
//添加
if(status.equals("add"))
{
message=ParameterUtils.getString(request,"message");
String city_cn_name=ParameterUtils.getString(request,"city_cn_name");//城市中文名称
String city_en_name=ParameterUtils.getString(request,"city_en_name");//城市英文名称
String country_id=ParameterUtils.getString(request,"country_id");//国家
String province_id=ParameterUtils.getString(request,"province_id");//省份/大洲
if(city_cn_name==null||city_cn_name.equals("")){
out.print("city_cn_name 城市中文名称不能为空");
return;
}
if(city_en_name==null||city_en_name.equals("")){
out.print("city_en_name 城市英文名称不能为空");
return;
}
if(country_id==null||country_id.equals("")){
out.print("country_id 国家不能为空");
return;
}
if(province_id==null||province_id.equals("")){
out.print("province_id 省份/大洲不能为空");
return;
}
Dictionary_cityItem item=new Dictionary_cityItem();
item.setCity_cn_name(city_cn_name);
item.setCity_en_name(city_en_name);
item.setCountry_id(country_id);
item.setProvince_id(province_id);
Dictionary_cityBean bean=new Dictionary_cityBean();
int keyId=bean.addItemAndMaxId(item);
if(keyId>0)
{
item.setId(Integer.toString(keyId));
Dictionary_cityXmlBean xmlBean=new Dictionary_cityXmlBean();
xmlBean.addXmlItem(item);
}
}
%>
<html>
<head>
<title><%=titleName%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../../css/css.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../../js/check.js"></script>
<link href="../../css/date.css" rel="stylesheet" type="text/css">
<script src="../../js/ShowDate.js"></script>
<script language="javascript">
init();
</script>
</head>
<script language="javascript">
function back()
{
location="dictionary_city.jsp";
}
function Check()
{
var form=form1;
if(form.city_cn_name.value=="")
{
alert("请输入城市中文名称!");
form.city_cn_name.focus();
return;
}
if(form.city_en_name.value=="")
{
alert("请输入城市英文名称!");
form.city_en_name.focus();
return;
}
if(form.country_id.value=="")
{
alert("请输入国家!");
form.country_id.focus();
return;
}
if(form.province_id.value=="")
{
alert("请输入省份/大洲!");
form.province_id.focus();
return;
}
form.status.value="add";
form.message.value=1;
form.submit();
}
</script>
<body>
<form action="" method="post" name="form1" >
<table class="firsttable">
<tr>
<td align="center" valign="top">
<table class="centertable">
<tr>
<td></td>
</tr>
<tr>
<td align="center" class="addborder">
<table class="addTable">
<tr align="center" >
<td colspan="2">
<font class="message">
<%
if(message.equals("1"))
{
out.println("添加成功:继续");
}
%>
</font>
</td>
</tr>
<tr >
<td >城市中文名称:</td>
<td ><input name="city_cn_name" type="text" id="city_cn_name" value="" ></td>
</tr>
<tr >
<td >城市英文名称:</td>
<td ><input name="city_en_name" type="text" id="city_en_name" value="" ></td>
</tr>
<tr >
<td >国家:</td>
<td >
<select name="country_id" id="country_id" onChange="select_kind(this)">
<%
Dictionary_countryXmlBean dictionary_countryXmlBean=new Dictionary_countryXmlBean();
List dictionary_countryXmlList=dictionary_countryXmlBean.findXml();
Iterator dictionary_countryXmlE=dictionary_countryXmlList.iterator();
while(dictionary_countryXmlE.hasNext()){
Dictionary_countryItem dictionary_countryItem=(Dictionary_countryItem)dictionary_countryXmlE.next();
if(ParameterUtils.getString(request,"country_id").equals(dictionary_countryItem.getId()))
out.println("<option value='"+dictionary_countryItem.getId()+"' selected>"+dictionary_countryItem.getCountry_cn_name()+"</option>");
else
out.println("<option value='"+dictionary_countryItem.getId()+"' >"+dictionary_countryItem.getCountry_cn_name()+"</option>");
}
%>
</select>
</td>
</tr>
<tr >
<td >省份/大洲:</td>
<td >
<select name="province_id" id="province_id">
<%
Dictionary_provinceXmlBean dictionary_provinceXmlBean=new Dictionary_provinceXmlBean();
List dictionary_provinceXmlList=dictionary_provinceXmlBean.findXmlByCountry_id(ParameterUtils.getString(request,"country_id"));
Iterator dictionary_provinceXmlE=dictionary_provinceXmlList.iterator();
while(dictionary_provinceXmlE.hasNext()){
Dictionary_provinceItem dictionary_provinceItem=(Dictionary_provinceItem)dictionary_provinceXmlE.next();
if(ParameterUtils.getString(request,"province_id").equals(dictionary_provinceItem.getId()))
out.println("<option value='"+dictionary_provinceItem.getId()+"' selected>"+dictionary_provinceItem.getProvince_cn_name()+"</option>");
else
out.println("<option value='"+dictionary_provinceItem.getId()+"' >"+dictionary_provinceItem.getProvince_cn_name()+"</option>");
}
%>
</select>
</td>
</tr>
<tr >
<td colspan="2" align="center">
<input name="Button" type="button" class="button" onClick="Check()" value="确定">
<input name="Submit2" type="button" class="button" onClick="back()" value="返回">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" name="status" >
<input type="hidden" name="message" >
</form>
</body>
</html>
<script language="javascript">
function select_kind(obj)
{ //把产品的类别列出
var f2Array = new Array();
<%
dictionary_provinceXmlList=dictionary_provinceXmlBean.findXml();
for(int i=0; i<dictionary_countryXmlList.size(); i++)
{
Dictionary_countryItem dictionary_countryItem=(Dictionary_countryItem)dictionary_countryXmlList.get(i);
out.println( "f2Array["+dictionary_countryItem.getId()+"] = new Array();");
int j = 0;
for(int k=0; k<dictionary_provinceXmlList.size(); k++)
{
Dictionary_provinceItem dictionary_provinceItem=(Dictionary_provinceItem)dictionary_provinceXmlList.get(k);
if(dictionary_provinceItem.getCountry_id().equals(dictionary_countryItem.getId()))
{
out.println( "f2Array["+dictionary_countryItem.getId()+"]["+j+"] = new Option();");
out.println( "f2Array["+dictionary_countryItem.getId()+"]["+j+"].value = "+dictionary_provinceItem.getId()+";");
out.println( "f2Array["+dictionary_countryItem.getId()+"]["+j+"].text = '"+dictionary_provinceItem.getProvince_cn_name()+"';");
j++;
}
}
}
%>
var form = form1;
var i = eval(obj.value);
form.province_id.length = 0;
if(obj.value=="") return;
for(var j=0; j<f2Array[i].length; j++)
{
form.province_id.options[form.province_id.length] = f2Array[i][j];
}
}
</script>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?