rendered paste body<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import = "java.util.*"%>
<%@page import = "java.sql.*"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
// define functions to check for max values reached for checkbox question
var my_value_array = new Array();
var my_cnt_array = new Array();
function checkbox_max_select(element,variable,max) {
var index=-1;
var my_length=my_value_array.length;
for(var i=0; i< my_value_array.length;i++) {
if(my_value_array[i] == variable) {
index=i;
break;
}
}
if(index == -1) {
my_value_array[my_length]=variable;
my_cnt_array[my_length]=0;
index=my_length;
}
var chk_value=element.checked;
if(chk_value) {
if((my_cnt_array[index]+1) > max) {
element.checked=false;
alert("You may select "+max+ " boxes at most. To change a selection, uncheck one box, then check another box.");
} else {
my_cnt_array[index]=my_cnt_array[index]+1;
}
} else {
if(my_cnt_array[index] > 0) {
my_cnt_array[index]=my_cnt_array[index]-1;
}
}
}
function checkbox_set_cur_cnt(element,variable,max) {
var index=-1;
var my_length=my_value_array.length;
for(var i=0; i< my_value_array.length;i++) {
if(my_value_array[i] == variable) {
index=i;
break;
}
}
if(index == -1) {
my_value_array[my_length]=variable;
my_cnt_array[my_length]=max;
// index=my_length;
}
}
//function for checking if no seat is selected
function checkSeat(e)
{
e.value="booked";
var count=0;
for(i = 0; i < 20; i++){
var x = document.getElementById("seat"+i);
if(x.value=="booked")
count++;
if(count>4)
alert("crap");
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LoginLogic</title>
</head>
<body bgcolor="#CCCC55">
<%
String arr[];
arr = (String[])session.getAttribute("seats");
%>
<form name="form1" method="post" action="Confirm.jsp" >
<table width="661" height="357" border="1">
<caption align="top">
Seats availability
</caption>
<%
int i=0;int j=0;
for(i=0; i<5; i++){%>
<tr>
<%for(j=0; j<4; j++){%>
<td width="156"><label>
<div align="center"><%=(i*4)+j%>
<input type="button" name="seat<%=(i*4)+j%>" id="seat<%=(i*4)+j%>" value="<%=(i*4)+j%>" <%=arr[i*4+j]%> onclick="checkSeat(this)" />
</div>
</label></td>
<%}%>
</tr>
<%}%>
</table>
<label></label>
<p align = center>
<input type="submit" value="DONE" ><br/>
</p>
</form>
</body>
</html>