• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

Dynamic table

I have a jsp form called view.jsp.

When the user clicks the add button, a pop window would pop up and asks the user to enter the details such as

  Name of Color,
  Type of Color,
   Description,
When the user has entered the details, he presses the ok button on the pop up window, the data gets inserted into the database
(The user could add as many as color and details and table grows)

My problem is that i need to display the details of the color in a dynamic table( i don't know how) with a checkbox and the details
For example
Checkbox | Name of Color|Type of Color|Description

How do i add this to the dynamic table and i need not explicits refresh the view the jsp( i don't know how)

The name of table is Col
Fields
Colorid | typeColor| Desc|

Thanks
0
Jasbir21
Asked:
Jasbir21
  • 6
  • 5
  • 5
1 Solution
 
KaraaCommented:
the details  of color are coming from db or some where else?
0
 
KaraaCommented:
<%
String cname;/// coming from db
String   check="checked"; or check="";/// this check variable may have two values coming from database either "checked" or ""
%>
use some For loop

<td width="5"><input type="Checkbox" name="gar" value="pot" <%  out.print(check);%>><br></td>
<input name="color" type="text" id="colorname" value="<%=cname%>" size="19" align="top" width="110" >
0
 
KaraaCommented:
if u want to do SQL search of table from db u can use
String      str = "SELECT color,type,desc,checked FROM Col";
            rset = stmt.executeQuery(str);%>
<%
            while (rset.next())
                  {
                  String cname= rset.getString(1);
                  String type= rset.getString(2);
String desc= rset.getString(3);
String checked= rset.getString(4);

                  %>
                  <td width="5"><input type="Checkbox" name="gar" value="pot" <%  out.println(checked);%>><br></td>
<td ><input name="color" type="text" id="colorname" value="<%=cname%>" size="19" align="top" width="110" > </td>      
<td ><input name="type" type="text" id="type" value="<%=type%>" size="19" align="top" width="110" > </td>      
<td ><input name="desc" type="text" id="desc" value="<%=desc%>" size="19" align="top" width="110" > </td>                  <%      }      %>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jasbir21Author Commented:
Hi,
 
  I tried that but i got this error:server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NullPointerException
      org.apache.jsp.jsp2.orga_jsp._jspService(orga_jsp.java:259)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


Thanks
0
 
kennethxuCommented:
if you don't want to refresh the view.jsp, then there is an example of how to do it with javascript:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20676182.html
it was about another question but have the right example in it.
0
 
KaraaCommented:
The reason may be you have not initialised JSP variables
0
 
KaraaCommented:
it is better you post your code
0
 
Jasbir21Author Commented:
....java bean classes and connection with database
My problem is that when the user clicks the new button , the project.jsp should be displayed and when the info is entered the page needs to be refreshed or what ever (dynamic table needs to be displayed)
Could anyone plssssssssss help me , i really  needs this urgently

This is the part of the code:

<table border="2" BGCOLOR="#FFFFF0" width="80%" CELLPADDING="4">
<tr>
<td>
<input type="checkbox" name="chk" value="yes" style="background=cornsilk; border=0;">
</td>
<td>
Project Name
</td>
<td>
Description
</td>
<td>
Duration
</td>
<td>
Skills Required
</td>
</tr>
</table>

</p>
<input type=button value="New" >
<input type=button value="Edit">
<input type=button value="Delete">
</p>
<input type="submit" value="Submit">
</form>
</font>
</body>
</html>
0
 
kennethxuCommented:
>> Could anyone plssssssssss help me , i really  needs this urgently
we need more information to help you, you might want to help you self by response to us quickly.

can you please post what you have for your view.jsp? or let us know if you don't even know where to start.
0
 
Jasbir21Author Commented:
so sorry for the late response.

 I don't know where to start, except that my connections the database and everything works fine, and for the dynamic table part i just have that html code,
The rest of the form is just enterin g data...


Thanks
0
 
kennethxuCommented:
assuming you know how to get a resultset from database:

<% while( resultSet.next() ) { %>
<tr>
<td>
<input type="checkbox" name="chk" value="yes" style="background=cornsilk; border=0;">
</td>
<td>
<%=resultSet.getString( "ProductName" )%>
</td>
<td>
<%=resultSet.getString( "Description" )%>
</td>
<td>
<%=resultSet.getString( "Duration" )%>
</td>
<td>
<%=resultSet.getString( "SkillsRequired" )%>
</td>
</tr>
<% } %>
0
 
Jasbir21Author Commented:
Hi,
  Sorry for not being clear from the beginning :
<input type=button value="New" >
<input type=button value="Edit">
<input type=button value="Delete">

 My problem when the user clicks the new button, a window should pop up, called project.jsp.
Where the user is able to enter data into table project.When the user clicks submit button on project.jsp the dynamic table in view.jsp needs to be displayed.
There is also other information entered by the user on view.jsp.
I mean, how can it be done if the user
clicks new, the project.jsp pops-up ,user enters info press submit, it gets displayed on view.jsp(dynamic table) with other info of user..


Thanks
0
 
kennethxuCommented:
so your question is rather on how to handle the popup windows instead how to display a dynamic table with data from database.

read this thread from beginning to the end and you should know what you need to do.

Let me know if you have futher enquires.
0
 
kennethxuCommented:
0
 
Jasbir21Author Commented:
thank you ans sorry for the late reply....
0
 
kennethxuCommented:
glad to know your problem is resolved and thanks for the A grade.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now