Hi,

My below code is working only if there is a single row. could you please help me in doing it for all the rows retrieved from the database.

view plaincopy to clipboardprint?

<%@page import="java.util.concurrent.CountDownLatch"%>  
<%@include file="DBCon.jsp" %>  

<html>  
    <head><script type="text/javascript">  
       function invoke(but)  
            {  
                if(but==5)  
                {  
                    document.abc.action="Users_2.jsp";  
                }  
                else if(but==6)  
                {  
                    document.abc.action="Up_Query_DB.jsp";  
                }  
                    document.abc.submit();  
            }  
             function UnBloc1()  
            {  
                document.getElementById("updat1").style.display="block";  
                document.getElementById("Ans").style.display="block";  
            }  
        </script> </head>  
<body>  
    <table border="1px">  
<%  
try{  
    ps=con.prepareStatement("Select DBID,Query_Raised,TR from Scope1 where TR!='null' AND (Query_Answered is null OR Count is null)");  
    rs=ps.executeQuery();  
    out.println("<b>QueryRaised</b>");  
       while(rs.next())  

        {  
           %>  
                      <tr>  
                      <form name="abc" method="post" action="">  
                      <td><center><input type="text" value="<%=rs.getString("DBID")%>" readonly="readonly" id="xyz" name="xyz" size="100"></center></td>  
                      <td><input type="Submit" value="Resume" name="Resume" id="Resume" onClick="invoke(5)"></td>  
                      <td><input type="button" value="Update Answer" onClick="UnBloc1()"></td>  
                      <td><input type="text" name="updat1" style="display: none" id="updat1" style="border:hidden"/></td>             
                      <td><input type="Submit" value="Submit Answer" style="display:none" name="Ans" id="Ans" onClick="invoke(6)"/>  
                      </td>  

                      </form></tr>  

        <% }  
rs.close();  
con.close();  
}  
catch(Exception e)  
               {  
    out.println(e);  

}  
%>  
        </table></body></html> 

please help me with it.

Thanks

the main problemm of your jsp is you are repeating form tag for all record in the database.but a jsp page support forms with unique name only

what i mean is if have 5 records in database according to your code creates same
<form name='abc' >..some jsp code here ....</form>
content for 5 times (i mean repeated 5 times)

so that javascript does not recognise all these 5 <form> tags with the same name
(i mean <form name="abc"> )

it recognise first appeared <form> tag only

so that this is the main reason of your problem i think

just check it once

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.