Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to dynamically set values in check box

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
sir in my application i have to display notes made for a particular date now as there can be more than one note for a particular date. now i want that user can modify or delete particular notes into the database by checking them with the help of check box. now how to set the values in check box so that modification or deletion can be done. There is also a dynamically generated id for each note how can i use it. please help

fetchnotes.java

List list=new ArrayList();

response.setContentType("text/html");
PrintWriter out = response.getWriter();
System.out.println("Oracle Connect Example.");
Connection conn = null;
String url = "jdbcracle:thin:@localhost:1521:xe";
String driver = "oracle.jdbc.driver.OracleDriver";
String userName = "system";
String password = "mint";
Statement st;
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url,userName,password);
System.out.println("Connected to the database");

String ndate = request.getParameter("date");
String eid = request.getParameter("empid");
String strar[] = ndate.split("/");
String cdate = strar[0]+"/" + strar[1]+"/"+ strar[2];
if(eid==null||eid=="Enter Your Employee ID"){response.sendRedirect("viewnotes.jsp");}
String query = "select * from CNMS_NOTES where emp_id='"+eid+"' and note_date='"+cdate+"'";

Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(query);


while(rs.next()){
list.add(rs.getString("note_date"));
list.add(rs.getString("title"));
list.add(rs.getString("description"));
out.print(rs.getString(5));
}

}
catch(Exception e){out.print(e);}

request.setAttribute("description",list);
RequestDispatcher rd = request.getRequestDispatcher("/displaynotes.jsp");
rd.forward(request, response);
}
}

and to display the notes display.jsp

table class="t" border="1" width="650" align="center" >
<tr><td><form>
<tr>
<td ></td>
<td >Date</td>
<td >Title</td>
<td >Description</td>

</tr>
<% Iterator itr;%>
<% List data=(List)request.getAttribute("description");

int k=data.size();
request.setAttribute("size",k);
for(itr=data.iterator();itr.hasNext(); ){
%>

<tr class="a">
<td><input type="text" value="<%=request.getAttribute("size")%>"></td>
<td><input type="checkbox" name="cbdate" value="<%=request.getParameter("checkeddate") %>"></td>
<td ><input type="text" name="checkeddate" value="<%=itr.next()%>" class="b"></td>
<td ><input type="text" name="checkedtitle" value="<%=itr.next()%>" class="b"></td>
<td ><textarea cols="39" rows="3"><%=itr.next()%></textarea></td>

</tr>

<%}

%>
<table><table border="1" ><tr>
<td><input type="submit" value="MODIFY" onclick="this.form.action='expriment.jsp';"></td>
<td><input type="submit" value="DELETE" onclick="this.form.action='abc.jsp';"></form></td></tr>
</table>

</body>
</html>
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not post the same question more than once.
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
    Bookmark Topic Watch Topic
  • New Topic