hai, i am creating a form which the code is included below i want to hide the tables initially and after i click go i want to display the tables with result.so any help is appreciated much
<%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-logic"
prefix="logic"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sd" uri="/struts-dojo-tags"%>
<html>
<head>
<script language="javascript" src="datetimepicker.js">
</script>
</head>
<body bgcolor="#505050">
<table id="table1" style="display:block;">
<html:form action="/ZoneReportAction">
<table bgcolor="#808080" align="center" border="1" width="55%">
<tr colsapn="3">
<td
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">From <html:text
property="fromDate" size="13" maxlength="13" /> <!-- <input type="text" name="fromDate" id="fromDate" size="13" maxlength="13"> -->
<a href="javascript:NewCal('fromDate','ddmmyyyy')"><img
src="images/cal.gif" width="16" height="16" border="0"
alt="Pick a date"> </a></td>
<td
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">To <html:text
property="toDate" size="13" maxlength="13" /> <!-- <input type="text" name="toDate" id="toDate" size="13" maxlength="13"> -->
<a href="javascript:NewCal('toDate','ddmmyyyy')"><img
src="images/cal.gif" width="16" height="16" border="0"
alt="Pick a date"> </a></td>
<td
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;text-align:justify;">Zone 
<html:select name="ZoneReportForm" property="zone"
style="font-family:calibri;">
<html:option value="0">--Select Zone--</html:option>
<%-- <html:option value="1">All</html:option> --%>
<html:optionsCollection name="ZoneReportForm" property="zoneList"
label="zoneName" value="zoneId" />
</html:select>
</td>
<td><html:submit value="Go" property="method"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;background-color:#808080;width=55 height=0" />
</td>
</tr>
</table>
<br>
<br>
<!-- 'list' is the session String -->
<table id="results" border="1" align="center"
style="background-color:#808080;width:900px;">
<table style="display:none;">
<tr align="center" hidden="true"
style="color:White;background-color:#808080;font-family:calibri;height:20px;">
<th rowspan="2" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Zone</th>
<th colspan="4" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Revenue</th>
<th colspan="4" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Cost</th>
<th rowspan="2" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">P&L</th>
<th rowspan="2" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Trend</th>
</tr>
<tr hidden="true">
<th align="center"
style="color:white;font-family:calibri;font-size:12pt;font-weight:normal;">Capital</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Commodity</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Others</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Total</th>
<th align="center"
style="color:white;font-family:calibri;font-size:12pt;font-weight:normal;">Rent</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Salary</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Others</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Total</th>
<a href="#" onclick="setTable('results');return false"></a>
<table id="results" style="display:block;">
</tr>
<%
boolean even = false;
%>
<logic:present name="list">
<logic:iterate id="ZoneRecord" name="list">
<%
even = !even;
%>
<tr bgcolor="<%=even ? "#B7D3F5" : "#D6E0F5"%>"
style="font-family:calibri;font-size:11pt;font-weight:normal;heigth="5">
<td><a
href="ZoneReportAction.do?rowId=<bean:write name="ZoneRecord" property="zoneName" />"><bean:write
name="ZoneRecord" property="zoneName" /> </a>
</td>
<td align="right"><bean:write name="ZoneRecord" property="capitalBrok" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="commBrok" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="otherBrok" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="totalBrok" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="rent" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="salary" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="otherCost" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="totalCost" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="pl" />
</td>
<td align="center"><a
href="ZoneTrendAction.do?rowId=<bean:write name="ZoneRecord" property="zoneName" />">Trend</a></td>
</tr>
</logic:iterate>
</logic:present>
<!-- total for zone table -->
<logic:present name="totZoneRecord">
<logic:iterate id="ZoneRecord" name="totZoneRecord">
<tr bgcolor="#D6E0F5"
style="font-family:calibri;font-size:11pt;font-weight:bold;color:Brown;heigth="5";">
<td><bean:write name="ZoneRecord" property="zoneName" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="capitalBrok" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="commBrok" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="otherBrok" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="totalBrok" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="rent" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="salary" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="otherCost" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="totalCost" />
</td>
<td align="right"><bean:write name="ZoneRecord" property="pl" />
</td>
<td></td>
</tr>
</logic:iterate>
</logic:present>
</table>
<br>
<br>
<table id="results" style="display:none;" border="1" align="center"
style="background-color:#808080;width:900px;">
<tr align="center"
style="color:White;background-color:#808080;font-family:calibri;font-weight:normal;height:20px;">
<th rowspan="2" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Zone</th>
<th rowspan="2" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Territory</th>
<th colspan="4" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Revenue</th>
<th colspan="4" align="center"
style="color:White;font-family:calibrifont-size:12pt;font-weight:normal;">Cost</th>
<th rowspan="2" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">P&L</th>
<th rowspan="2" align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Trend</th>
<tr>
<th align="center"
style="color:white;font-family:calibri;font-size:12pt;font-weight:normal;">Capital</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Commodity</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Others</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Total</th>
<th align="center"
style="color:white;font-family:calibri;font-size:12pt;font-weight:normal;">Rent</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Salary</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Others</th>
<th align="center"
style="color:White;font-family:calibri;font-size:12pt;font-weight:normal;">Total</th>
<a href="#" onclick="setTable('results');return false"></a>
<table id="results" style="display:block;">
</tr>
<%
boolean even1 = false;
%>
<logic:present name="listTerr">
<logic:iterate id="TerritoryRecord" name="listTerr">
<%
even1 = !even1;
%>
<tr bgcolor="<%=even1 ? "#B7D3F5" : "#D6E0F5"%>"
style="font-family:calibri;font-size:11pt;font-weight:normal;heigth="5">
<td><bean:write name="TerritoryRecord" property="zoneName" />
</td>
<td><bean:write name="TerritoryRecord"
property="territoryName" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="capitalBrok" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="commBrok" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="otherBrok" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="totalBrok" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="rent" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="salary" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="otherCost" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="totalCost" />
</td>
<td align="right"><bean:write name="TerritoryRecord" property="pl" />
</td>
<td align="center"><a
href="TerritoryTrendAction.do?rowId=<bean:write name="TerritoryRecord" property="territoryName" />">Trend</a></td>
</tr>
</logic:iterate>
</logic:present>
</table>
</html:form>
</body>
</html>
You can use javascript. Here is an example of simple jsp code which is having a table consists of database data and a Go button. Using the style attribute, we have made table invisible. But, when the user click Go button, table will be visible with all the data.
<%@page language="java"%>
<%@page import="java.sql.*"%>
<script>
function sh(){
document.getElementById("tab").style.visibility="visible";
}
</script>
<input type="button" value="Go" onclick="sh();"><br>
<table border="1" id="tab" style="visibility:hidden;">
<%
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td><td><input type="text" name="address" value="<%=rs.getString("address")%>"></td><td>Contact No</td><td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td><td><input type="text" name="email" value="<%=rs.getString("email")%>"></td></tr>
<%
}
}
catch(Exception e){}
%>
</table>