how can i hide and show tables

how can i hide and show tables

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&nbsp<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&nbsp<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&nbsp
                    <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>
View Answers

June 20, 2012 at 3:43 PM

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>









Related Tutorials/Questions & Answers:
how can i hide and show tables
how can i hide and show tables  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 <
JSP hide and show tables
JSP hide and show tables In this tutorial, you will learn how to hide and show html tables using javascript in jsp. Here is an example of simple jsp code which is having a table consists of database data and a Go button. Using
Advertisements
How can I show users privileges in MySQL?
How can I show users privileges in MySQL?  Hi, How can I show user's privileges in MySQL? I want to know what is accessible to user in MySQL database. How to check this? Thanks   Hi, To view grant for a user you can
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
i want to know how a slide will hide
i want to know how a slide will hide  when im click on the button then im getting a slide, but when im click on the another button this slide will be hide.. and here im using logic iterate to getting the values from action class
i want to know how a slide will hide
i want to know how a slide will hide  when im click on the button then im getting a slide, but when im click on the another button this slide will be hide.. and here im using logic iterate to getting the values from action class
can i insert values into two tables by a query - JDBC
can i insert values into two tables by a query  hi all, can i insert values into two tables by a query Thanks Bala k
Show Hide Text Javascript - Java Beginners
Show Hide Text Javascript  Please tell me how to show hide text using Java Script
How to hide and show some field on a radio button click
How to hide and show some field on a radio button click  This is my...; </td> </tr> </table> I want bank name... is clicked.and they should be visible when by cheque radio button is clicked. I have
hide and show result in jsp
hide and show result in jsp  what codes do i have to change to make my result display if only i enter the correct value? suppose if i click search... will be shown. i suppose to put an if statement,but im not sure where to put it. before
Jquery Hide and Show Div
that illustrates how to can hide and show HTML elements with the hide() and show...Using jQuery effects one can perform lots of task such as Hide, Show, Toggle... and Hide methods in Java. .show() in jQuery is used to display the matched elements
show, hide, disable components on a page with struts - Struts
show, hide, disable components on a page with struts  disabling a textbox in struts.. in HTML its like disable="true/false" how can we do it in struts
Toggle hide/show by clicking same button
Toggle hide/show by clicking same button In this tutorial, we will discuss about how to toggle hide/show by clicking button. In the given below 2 example, there is button ,by clicking on it, the paragraph will hide/show . In first
Hide/Show paragraph by button click
Hide/Show paragraph by button click In this tutorial, we will discuss about how to hide/show paragraph by clicking on button using jQuery. In the below... to show Paragraph</button> <p>This will Hide after clicking button<
JavaScript Show Hide table
JavaScript Show Hide table...; In this section, we are going to show and hide table on clicking the button using...;html> <h2>Show or Hide table in JavaScript</h2> <
Hide show HTML forms using javascript
Hide show HTML forms using javascript  How to hide a HTML form in my application using JavaScript?   HTML Code to create checkbox <...;div id="yourDiv"> ...other forms... </div> JavaScript function to hide
how to hide and unhide folders in java
how to hide and unhide folders in java   i want to hide folder along with its contents and unhide later
How can I do it? .click();
How can I do it? .click();  I have a very unusual problem. I want...("a"); x.click(); </script> So it's click on an element witch one Id's is "a", but I want that it make mouseup in this element. How can I do it, because if I write
How can I learn Java?
How can I learn Java?  Hi, I have just completed a course in HTML and C programming language. I have some programming experience in visual basic... programming. How can I learn Java? in shortest possible time. I mean I just want to begin
how should i can solve
how should i can solve  Web based program - Input - Person's contact details with Passport Number as Unique Key. Save data in to oracle / MySQL. Output - List of Persons saved in the database. Technology to be used - JSP
how can i display a editable result of form?
show the result but i can not modify the result. how can i display modifyable...how can i display a editable result of form?  how can i display a editable result of form? i know how to display form result but the result
Help with jQuery show hide div script - JSP-Interview Questions
Help with jQuery show hide div script  Hi guys, I have a jquery script for showing and hiding the content inside, between two divs, controlled with radiobuttons. I like to use the same jquery script for another group of divs
Dojo Show and Hide Dialog
Dojo Show and Hide Dialog         In this example, you will learn dojo show and hide... box. Try Online: Show and Hide DialogADS_TO_REPLACE_1 Here
Learn how to take MySQL Backups and restore the same.
Learn how to take and then restore the MySQL database backup. You can use mysqldump utility to take the backup of MySQL database and tables with or without..., you can do it manually or take the help of cron script. The cron script
how can i display a pdf file in a jtextarea
how can i display a pdf file in a jtextarea  I need to display a pdf file in a jtextfield or in a jtextarea.Atlest i need to displat it in a jframe.I have a button and while clicking on it ,i need to choose the pdf file and need
how can i add hibernate plugin to eclipse?
how can i add hibernate plugin to eclipse?  how can i add hibernate plugin to eclipse
how i can get jqfade.js library
how i can get jqfade.js library  how i can get jqfade.j script library
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface arith { int a=5; int b=8; void add(); void mul(); void sub(); void
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface arith { int a=5; int b=8; void add(); void mul(); void sub(); void
how can i remove newline characters and tabs
how can i remove newline characters and tabs   how can i remove newline characters and tabs ? but i wont to using GUI .please help
how can i make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
how can i create a discussion forum?
how can i create a discussion forum?  how can i create a discussion forum for my e- mentoring site for women which can be used by a registered user only. i am using jsp and servlets and i am working with netbeans 6.8.
How can I learn Java in 5 minutes
How can I learn Java in 5 minutes  Hi, I am searching for the tutorials to learn Java programming. I don't know how easy or difficult is Java.... It will be helpful for me if someone gives me tutorials to learn Java. How can I
How can I to my database to my application
How can I to my database to my application  How can I to my database to my application   Hi, Please see the JDBC discussion thread.ADS_TO_REPLACE_1 Thanks
How can i modify my account in roseindia
How can i modify my account in roseindia  Presently am not using my gmail id. I have to modify my roseindia account. Please send the answer to following mail id
How can I protect my database password ?
How can I protect my database password ?   How can I protect my... in as plain text. What can I do to protect my passwords... a database over the internet. I have concerns about the security of the database
how can i set an object in focus
how can i set an object in focus  There is a Canvas object in my game... on the Board . Basically i am working on snake game project, and i want is when... i am facing is after clicking button gamescreen appearing on window but snake
How can I master Java in one month?
How can I master Java in one month?  Hi, I wish to learn Java programming in one month. I have little experience in c programming and PHP programming. Is there any way to learn Java quickly. How can I master Java in one month
how can i print the selected content of a frame
how can i print the selected content of a frame  hello sir, I am designing a bill calculate program. I want to print the bill in crystal form. I want to skip all the text fields shapes and all the button from the frame.. but all
How can i use Facebook connect button
How can i use Facebook connect button  Please to meet you all guys I wonder how can i use this Connect to facebook for me to post in a particular... http://likekhevy4.blogspot.com/ How can i apply this kind of comment with "Connect
how can i close a frame. - Java Beginners
how can i close a frame.  Hi, My question is how can we close... frames as i go on clicking button...........can we have like when i click on button...............my target is when i click on that button, a new frame is coming and updated table
How can I create sessionfactory in Hibernate?
How can I create sessionfactory in Hibernate?  HELLO, How can I create sessionfactory in Hibernate? If you can explain me with example that would... with the links below: Hibernate 4 Hibernate Session Factory I hope
javascript hide element
javascript hide element  How can we hide / show HTML elements using JavaScript
How can I get IBM certification for free?
How can I get IBM certification for free?  Hi, I am beginner in Data...: How can I get IBM certification for free? Try to provide me good examples or tutorials links so that I can learn the topic "How can I get IBM
How can I become a data scientist for free?
How can I become a data scientist for free?  Hi, I am beginner... to learn: How can I become a data scientist for free? Try to provide me good examples or tutorials links so that I can learn the topic "How can I become
How can I become a good data scientist?
How can I become a good data scientist?  Hi, I am beginner in Data...: How can I become a good data scientist? Try to provide me good examples or tutorials links so that I can learn the topic "How can I become a good data
How can I get into big data?
How can I get into big data?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can I... can learn the topic "How can I get into big data?". Also tell me
How can I learn Hadoop easily?
How can I learn Hadoop easily?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can... that I can learn the topic "How can I learn Hadoop easily?". Also tell

Ads