how can i hide and show tables

Ads
 

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>

Ads









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
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
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
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
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 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.
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
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
Jquery Hide and Show Div
Using jQuery effects one can perform lots of task such as Hide, Show, Toggle... to can hide and show HTML elements with the hide() and show() methods: Example... in HTML can be shown or hide on button click method in jQuery. The jQuery show
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 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 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 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
How can I change UIButton title color?
How can I change UIButton title color?  Hi, I have a button in my iPhone/iPad application. I want to change the color of the text when user clicks on it making it selected. Provide me good example code. Thanks   Hi
How I can cast a variable in Scala?
How I can cast a variable in Scala?  Hi, Trying Big Data and now I... an object of Graphics and you wan to cast it to Graphics2D then you can use following code: g.asInstanceOf[Graphics2D]; Similarly you can apply this logic to all
How I can cast a variable in Scala?
How I can cast a variable in Scala?  Hi, Trying Big Data and now I... an object of Graphics and you wan to cast it to Graphics2D then you can use following code: g.asInstanceOf[Graphics2D]; Similarly you can apply this logic to all
How can i search and insert within a query
How can i search and insert within a query  if it is possible that for eg: Retrieve seat numbers sql tables bases of some conditions eg batch semester and degree if i search batch 2008 , semester first and degree bscs then search

Ads