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

📄 choosecoursedo.jsp

📁 基于ssh框架
💻 JSP
字号:
<%@ page language="java" import="java.util.*,com.zzu.dao.entity.*" pageEncoding="gbk"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%
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>学生选课页面</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="styles.css">
	-->

	<script type="text/javascript">
	
		

	//给array 添加一个remove()
	
	function RemoveArray(array,attachId) 
	{ 
		var f=false; 
		for(var i=0,n=0;i<array.length;i++) 
		{ 
			if(array[i]!=attachId) 
			{ 
			array[n++]=array[i] 
			}else 
			f=true; 
		} 
		if(f==true) 
		array.length -= 1; 
	} 
	
	Array.prototype.remove = function (obj) { 
	return RemoveArray(this,obj); 
	}; 
	
	var choice=new Array();
	
	 function courseselect(id)
	 {
	  	 alert(id);
	  	 
	  	 var courses=document.getElementById("yourchoices").value;//当前选定的“选课”总数
	  	 var str=document.getElementById(id).value;//当前选定的“选课”值
	  	 if(courses!="")
			{
		
				document.getElementById("yourchoices").value+="-";
			}
			
			if(document.getElementById(id).checked==true)
			{
				choice.push(str);//在数组choice中添加当前“选课”元素
				a=choice.join("-");
				document.getElementById("yourchoices").value=a;
				choice.add(id);
				document.getElementById("yourchoices").value+=id;
				
			}else{
				choice.remove(str);//在数组中移除该"选课"的值
				a=choice.join("-");
				document.getElementById("yourchoices").value=a;//取消后的选课
			}
			
	}
		
		
	</script>
  </head>
  
  <body>
    <%
    	Student student=(Student)request.getSession().getAttribute("student");
    	if(student==null){
    %>
     <jsp:forward page="../syslogin.jsp"></jsp:forward>
	<%} %>
  
  
    ${student.sname },欢迎你!<br/>
   
   <a href="student/updateInfo.jsp" />修改个人信息</a>
    <a href="student.do?operate=chooseCourseList&sno=${student.sno }" >我的选课列表</a>
    <a href="student.do?operate=chooseCourseDo&sno=${student.sno }" />我要选课</a>
    <a href="student.do?operate=exitCourseDo&sno=${student.sno }" >我要退课</a>
    <a href="student.do?operate=seeGrade&sno=${student.sno }" >查看成绩</a>
    <a href="book.do?operate=booksubmit&sno=${student.sno }" >进入留言簿</a>
    <a href="student/exitsystem.jsp?sno=${student.sno }" >退出系统</a>
    
 	<br/><br/>
 	<li>进入 chooseCourseList.jsp</li>
 	<hr/>
 	   <% 
 	   			
 	   			ArrayList allcourselist=(ArrayList)request.getAttribute("allcourselist");
 	   %>
 	   <form action="student.do" method="post">
 	   	<table align="center">
 	   		<tr><td>
 	   			教师
 	   		</td>
 	   		<td>
 	   			课程
 	   		</td>
 	   		<td>
 	   			选择
 	   		</td></tr>
 	   		<input type="hidden" name="operate" value="chooseCourseDone" />
 	   		<input type="hidden" name="sno" value="${student.sno }" />
 	   		
 	   		<%
 	   			for(int i=0;i<allcourselist.size();i++)
 	   			{
 	   				Tc tc=(Tc)allcourselist.get(i);
 	   		 %>
 	   			<tr><td>
 	   			<%=tc.getTeacher().getTname() %>
 	   		</td>
 	   		<td>
 	   			<%=tc.getCourse().getCname() %>
 	   		</td>
 	   		
 	   			
 	   		<% 
 	   			ArrayList mylist=new ArrayList();
 	   			mylist=(ArrayList)request.getAttribute("mycourselist");
				String cno=tc.getCourse().getCno();
				System.out.println("===选修课程列表cno:"+cno);
				Object obj=(Object)cno;
 	   			if(null!=mylist&&mylist.contains(obj))
 	   			{
 	   		 %>
 	   		<td>
 	   			已选课程
 	   		</td>
 	   		   	<%}else{ %>	
 	   		   	<td>
 	   			${tc.course.cno }<input id="<%=tc.getCourse().getCno() %>" type="checkbox" name="courseckb" value="<%=tc.getCourse().getCno() %>" 
 	   			onclick="courseselect(this.value)" />
 	   			</td>
 	   		
 	   		   	<%} %>
 	   		   	
 	   		   	
 	   		   	</tr>
 	   		<%
 	   			}
 	   		%>
 	   		
 	   		你选择的是:<input type="text" size="50" name="yourchoices"/>
 	   		<tr><td>&nbsp;</td><td><input type="submit"  value="确定"/><input type="reset"  value="取消"/> </td><td></td>&nbsp;</tr> 	
 	   		 
 	   	</table>
 	   </form>
 	   
    
  </body>
</html>

⌨️ 快捷键说明

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