<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*,com.xploits.oaudlc.connection.*" errorPage="" %>
<%
String dept = "";
String all[] = new String[2];
String faculty = request.getParameter("faculty");
String department = request.getParameter("department");
String programtype = request.getParameter("programtype");
String sname = request.getParameter("sname");
String to_load = request.getParameter("to_load");if(session.isNew())	{
	session.invalidate();
	response.sendRedirect("../index.jsp");
	return;
}				
else if(to_load.equals("dpt"))	{
		Connection conn = null;
		try{
			javax.naming.InitialContext ctx = new javax.naming.InitialContext();
			javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/oaudlc");
			conn = ds.getConnection(); 	
			all = SQLUtil.filldptchoices(conn, programtype, faculty);
			conn.close();
			conn = null;
			}	catch(Exception ex)	{
				conn = null;
			}	finally	{
				try	{
					if(conn != null)	{
					conn.close();
					}
					conn = null;
				}	catch(Exception ex)	{
					conn = null;
				}
			}
%><SELECT name="department_f" class="form_field" id="department_f" onchange="changecourse(this.value)">
  <option value="">Select a Department</option>
  <%= all[0] %>
</SELECT>
<script type="text/javascript">
document.getElementById('course_1').innerHTML = '<%= all[1] %>'
</script>
<%			
}
else if(to_load.equals("course"))	{
		Connection conn = null;
		try{
			javax.naming.InitialContext ctx = new javax.naming.InitialContext();
			javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/oaudlc");
			conn = ds.getConnection(); 	
			dept = SQLUtil.fillcoursechoices(conn, programtype, faculty, department);
			conn.close();
			conn = null;
			}	catch(Exception ex)	{
				conn = null;
			}	finally	{
				try	{
					if(conn != null)	{
					conn.close();
					}
					conn = null;
				}	catch(Exception ex)	{
					conn = null;
				}
			}
			if(dept.equals(""))	{
				//out.print(faculty);
			}
%>
<SELECT name="course_f" class="form_field" id="course_f">
  <option value="">Select a Course</option>
  <%= dept %>
</SELECT>
<%	
}	else	{
//out.print("Efrebo");
}
%>
