Results 1 to 4 of 4
  1. #1
    reubenmk is offline Member
    Join Date
    Aug 2010
    Posts
    6
    Rep Power
    0

    Default How to display data against row clicked on html table?

    I have a jsp page on which when i click submit button retrieves a resutlset(table orders) from the servlet
    and displays on the same jsp page in a html table format. now i know that html rows have onclick event.My
    requirement here is that when i click a row i shud pick one particular item(example order_no) of that row
    and based on this order_no i want to retrieve data from another table called trades and display those records
    next to this main table. and it shud change as i click another row.Now i just have an alert ->which means when i
    click any row of the main table an alert message shows the order no of the row i clicked.But i want to display
    the trades of that orderno.i hope u understood my problem.Cud u pls tell me how to proceed.

    This is the code which im using to display the order table in the jsp page


    <%
    List orddet=(List)request.getAttribute("OrdersDet");
    if (orddet!=null){
    out.println("<table border=\"1\">");
    out.println("<tr>");
    out.println("<th>Trade Date</th>");
    out.println("<th>Order No</th>");
    out.println("<th>Security</th>");
    out.println("<th>Exchange</th>");
    out.println("</tr>");
    for (int i=0;i<orddet.size();i++)
    {
    Map obj=(Map) orddet.get(i);

    out.println("<tr onclick=\"Change('"+obj.get("ORD_NO")+"');\">");

    out.println("<td>"+obj.get("TRD_DATE")+"</td>");
    out.println("<td>"+obj.get("ORD_NO")+"</td>");
    out.println("<td>"+obj.get("SECURITY")+"</td>");
    out.println("<td>"+obj.get("EXCHANGE")+"</td>");
    out.println("</tr>");
    }
    out.println("</table>");
    }
    %>


    <script type="text/javascript">
    function Change(value)
    {
    alert("the orderno is "+value);
    }

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: How to display data against row clicked on html table?

    You need to read up on Ajax and the various ways to do summary/detail things (JSON string, full HTML plonked into a holder DIV, that sort of thing).

  3. #3
    vishnujava is offline Member
    Join Date
    Apr 2008
    Posts
    14
    Rep Power
    0

    Default Re: How to display data against row clicked on html table?

    Yes you should use Ajax...

  4. #4
    reubenmk is offline Member
    Join Date
    Aug 2010
    Posts
    6
    Rep Power
    0

    Default Re: How to display data against row clicked on html table?

    Hey thanks a lot both of u!!that really helped...

Similar Threads

  1. One JBUTTON DISPLAY DIFFERENT TEXTS WHEN CLICKED.
    By Nakinsige in forum New To Java
    Replies: 9
    Last Post: 01-08-2012, 05:36 PM
  2. how to display data in a table format using jstl tag
    By anand12356 in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 02-09-2011, 01:26 PM
  3. Replies: 1
    Last Post: 06-22-2009, 02:39 AM
  4. Display success message in same page when submit button is clicked
    By am17mu in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-29-2008, 10:56 AM
  5. Data formatting for the <display:table>
    By yuchuang in forum Web Frameworks
    Replies: 3
    Last Post: 12-14-2007, 10:52 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •