Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts how can i hide and show tables

Have Programming Question? Ask it here!
 
 
 


sai kumar
how can i hide and show tables
1 Answer(s)      2 years and 2 months ago
Posted in : Struts


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>

Advertisement
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
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
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
Show Hide Text Javascript - Java Beginners
Show Hide Text Javascript  Please tell me how to show hide text using Java Script
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
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
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
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<
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
JavaScript Show Hide table
JavaScript Show Hide table...; In this section, we are going to show and hide table on clicking the button using...;h2>Show or Hide table in JavaScript</h2> <script>
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 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 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
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 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 make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
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 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 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. Thanks
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 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 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 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 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 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 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
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
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 Dialog Here is the code: <
how can i simplify my java code
how can i simplify my java code  /* Create a program that prompts... c=0;int f=0;int i=0; int counter=0; int starter=0; int cot=1...)(Math.random() * 9 +cot); h = (int)(Math.random() * 9 +counter); i = (int
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
how can i export a .jar file include .mbd file?
how can i export a .jar file include .mbd file?  i have a project... a error that can't export .jar file width the .mdb file ? how can i import this .mdb file width the .jar file? and how can i run this file on the other computer
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
javascript hide element
javascript hide element  How can we hide / show HTML elements using JavaScript
How to Hide Button using Java Swing
How to Hide Button using Java Swing  Hi, I just begin to learn java programming. How to hide the button in Java programming. Please anyone suggest... Programming application how to hide the buttons using Java Swing. Please Visit
How can i Dispose Dialog box From LWUIT Component >
How can i Dispose Dialog box From LWUIT Component >  Hi All, i... to show a dialog when i press key "0". again if i press key "4" the Dialog should... is showing but after i press key 4, there is know response import
What is the default session time in php and how can I change it?
What is the default session time in php and how can I change it?  What is the default session time in php and how can I change
How many ways I can redirect a PHP page?
How many ways I can redirect a PHP page?   How many ways I can redirect a PHP page
 

 

 

DMCA.com