⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insert_student.jsp

📁 数据库系统教材中附录的课程设计accomodation宿舍管理系统源码
💻 JSP
字号:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'inserts_student.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<!--<link rel="stylesheet" type="text/css" href="<%=basePath %>/styles/insert_student.css">-->
	
	<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" /> 
	<script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="ext/ext-all.js"></script>
	<script type="text/javascript" src="ext/source/ext-lang-zh_CN.js"></script>
  </head>
  
<body>
<script type="text/javascript">
Ext.onReady(

function(){
	Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'side'; 
    
    var arr=[ [1, '大一'], [2, '大二'],[3, '大三'],[4, '大四'],[5, '研一'],[6, '研二'],[7, '研三'] ];   
    var reader = new Ext.data.ArrayReader(   
		{id: 0},   
		[   
			{name: 'value'},           
			{name: 'key'}      
		]
	);   
      
	var store=new Ext.data.Store({   
		reader:reader   
	});   
	store.loadData(arr);  
	
	var myForm = new Ext.form.FormPanel({
		title:"添加学生",
		width:425,
		frame:true,
		
		//items
		items: [
			//studentNum
			new Ext.form.TextField({
				id:"studentNum",
				name:'studentNum',
				fieldLabel:"学号",
				width:275,
				allowBlank:false,
				blankText:"Please enter the student number"
			}),
			
			//lname
			new Ext.form.TextField({
				id:"lname",
				name:'lname',
				grow:true,
				fieldLabel:"姓",
				width:275,
				allowBlank:false,
				blankText:"Please enter the last name"
			}),
			
			//fname
			new Ext.form.TextField({
				id:"fname",
				name:'fname',
                grow:true,				
				fieldLabel:"名",
				width:275,
				allowBlank:false,
				blankText:"Please enter the first name"
			}),
			
			//birthday
			new Ext.form.DateField({  
                fieldLabel:'birthday',
                name:'birthday',   
                format:'Y-m-d' ,  
                allowBlank:false,   
                //disabledDays:[0,6] , //不让选择周六,周日   
                //disabledDaysText:"周末要休息",     
                invalidText :"您输入了不该输入的字符"   
            }),   
			
			//sex
			new Ext.form.FieldSet({ //加一个FieldSet就把两个radio当作一组   
                border:false,                     
                title:'性别',   
                layout:'table',  //加这个属性 Radio 就是横着放的   
                items:[   
                    new Ext.form.Radio({   
                        labelSeparator:'',   
                        name:'sex',   
                        checked:true,
                        inputValue:'M',   
                        boxLabel:'男'   
                    }),   
                    new Ext.form.Radio({   
                        labelSeparator:'',   
                        name:'sex',   
                        checked:false, 
                        inputValue:'F',  
                        boxLabel:'女'   
                    })   
                ]   
            }), 
            
            //category
            //居然无法在后台获取像select一样option value的值,而获取的是text的值
            //所谓的combobox实质只是text的而已
            //option "valueField" must work with "hiddenName"
            //hiddenName: This is an autocreated hidden field that gets the value of what ever you select"
            new Ext.form.ComboBox({ //select   
                fieldLabel:'类别',
                name:'category', 
                hiddenName:'category',  
                editable:false,   
                triggerAction: 'all',   
                valueField:'value',   
                displayField:'key',   
                mode: 'local',   
                store:store   
            }),  
			
			//nationality
			new Ext.form.TextField({
				id:"nationality",
				name:'nationality',
				fieldLabel:"部门",
	            width:275,
				allowBlank:false,
				blankText:"Please enter the nationality"
			}),  
			
			//advisorNum
			new Ext.form.TextField({
	            id:"advisorNum",
	            name:'advisorNum',
				fieldLabel:"学生顾问号",
				width:275,
				allowBlank:false,
				blankText:"Please enter the advisorNum"
			}),
			
			//isSmoker
			new Ext.form.FieldSet({   
                border:false,                     
                title:'是否吸烟',   
                layout:'table',  
                items:[   
                    new Ext.form.Radio({   
                        labelSeparator:'',   
                        name:'isSmoker',   
                        checked:true,
                        inputValue:'1',   
                        boxLabel:'是'   
                    }),   
                    new Ext.form.Radio({   
                        labelSeparator:'',   
                        name:'isSmoker',   
                        checked:false,
                        inputValue:'0',   
                        boxLabel:'否'   
                    })   
                ]   
            }), 
			
			//city
			new Ext.form.TextField({
	            id:"city",
	            name:'city',
				fieldLabel:"城市",
				width:275,
				allowBlank:false,
				blankText:"Please enter the city"
			}),
			
			//street
			new Ext.form.TextField({
	            id:"street",
	            name:'street',
				fieldLabel:"街道",
				width:275,
				allowBlank:false,
				blankText:"Please enter the street"
			}),
			
			//postcode
			new Ext.form.TextField({
	            id:"postcode",
	            name:'postcode',
				fieldLabel:"邮政编码",
				width:275,
				allowBlank:false,
				blankText:"Please enter the postcode"
			}),
			
			//specialNeeds
			new  Ext.form.TextArea({      
                fieldLabel:'特殊需求',
                name:'specialNeeds',   
                hideParent:true,   
                preventScrollbars:true     
            }),
            
            //addtionalComment
            new  Ext.form.TextArea({     
                fieldLabel:'附加评论',
                name:'additionalComment',   
                hideParent:true,   
                preventScrollbars:true
            })
		],
		
		//buttons
		buttons: [
        {
			text:"提交",
			type:'submit',
			handler:function(){
				if(myForm.form.isValid()){//验证合法后使用加载进度条
                    Ext.MessageBox.show({
						title: '请稍等',
						msg: '正在提交...',
						progressText: '',
						width:300,
						progress:true,
						closable:false,
						animEl: 'loding'
                    });
						
                    //控制进度速度
                    var f = function(v){
                        return function(){
                            var i = v/11;
                            Ext.MessageBox.updateProgress(i, '');
                        };
                    };

                    for(var i = 1; i < 6; i++){
                        setTimeout(f(i), i*150);
                    }
                    
                    
					//提交到服务器操作
	                myForm.form.doAction(
						'submit',				
						{
							url:'<%=basePath%>insertStudent2.do',//servlet文件路径
							method:'post',//提交方法post或get
							params:'',
							
							//提交成功的回调函数
							success:function(form,action){
								if (action.result.msg=='success') {
									Ext.Msg.alert('操作成功',action.result.msg);
									//document.location='<%=basePath%>jsp/insert_family.jsp';
								}
								else
								if(action.result.msg=='existedStudent'){
								     Ext.Msg.alert('该学生已存在',action.result.msg);
								}                             
								else{
									Ext.Msg.alert('抱歉操作失败',action.result.msg);
								}
							},
							
							//提交失败的回调函数
							failure:function(){
								Ext.Msg.alert('错误','服务器出现错误请稍后再试!');
							}
                        }
					);	
				}
			}
		},
		
        {
			text:"重置",
			handler:function(){myForm.form.reset();}//重置表单
		}
		]	
	});
   
   
    win = new Ext.Window({
        id:'win',
        title:'添加学生',
        layout:'fit',   //之前提到的布局方式fit,自适应布局               
        width:450,
        height:600,
        plain:true,
        bodyStyle:'padding:5px;',
        maximizable:false,//禁止最大化
        closeAction:'close',
        closable:false,//禁止关闭
        collapsible:true,//可折叠
        plain: true,
        buttonAlign:'center',
        items:myForm//将表单作为窗体元素嵌套布局
    });
	// myForm.render(document.body);
	win.show(document.body);	
});
</script>
<div id="container">
	
</div>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -