Hi,I have a jsp form in which one static field for date and below a dynamic table having three fields one for employee name those are showing in this page dynamically from other table and two radio button one for present and the second for absent having same name(status) but different values(present,absent)when I select one radio button for text field then it insert only one value absent OR present for every text field name so please give me some help to solving this problem my code is here .......
<%-- Document : attendance_Management Created on : Apr 27, 2011, 10:32:25 AM Author : user03 --%> <%@page contentType="text/html" pageEncoding="UTF-8" import="java.sql.*,src.*,java.util.Enumeration,java.util.ArrayList,java.text.SimpleDateFormat,java.util.Date" session="true"%> <jsp:include page="header.jsp"/> <html> ' <% String username=(String)session.getAttribute("user"); System.out.println("Username is " +username); if(username==null) { response.sendRedirect("error.jsp"); } JdbcConnection conn=new JdbcConnection(); Connection con=null; Statement stmt=null; ResultSet rs=null; String sql=null; boolean bn=false; int i=0; ArrayList a1=new ArrayList(); %>' <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Attendance Management</title> <LINK rel="stylesheet" href="stylesheet/fac_css.css"> <script type="text/javascript"> function selectRadio() { if(doucment.getElementById(elementId)) document.getElementById("pre").value; } </script> </head> <body> <form name="myForm" method="post" action="add_attendance_sheet.jsp" > <div id="welcome"> <div id="welcome_in"> <div id="welcome_in_left">Attendance Management</div> <div id="welcome_in_right"> ' <% String login_user = (String)session.getAttribute("user"); Date dt=new Date(); SimpleDateFormat sd=new SimpleDateFormat("dd-MM-yyyy"); String att_date=sd.format(dt); %>' <div id="welcome_in_right_right">Welcome: <%=login_user%></div> <div id="welcome_in_right_left"><img src="images/afterlogintop_icon.jpg" width="42" height="30"></div> </div> </div> </div> <div id="container1"> <div style="height:3px; "></div> <table width="280" align="center" border="0" cellspacing="0" cellpadding="0" rules="rows" style="border:1px solid #cccccc;"> <tr> <td class="centerfont">Current Date</td> <td><input size="10" type="text" name="attendance_date" value="<%=att_date%>" id="aa"></td> <td> </td> </tr> <tr> <td colspan="3"><table id="attendance" width="100%" cellpadding="" cellspacing="" rules="all" style="border:0px solid #cccccc"> <tbody> <tr> <td class="centerfont" width="75">Staff Name</td> <td class="centerfont" width="10">Present </td> <td class="centerfont" width="10">Absent</td> </tr> <% try { con=(Connection)conn.getConnection(); stmt=(Statement)con.createStatement(); sql="Select staff_name from staff_manager"; rs=stmt.executeQuery(sql); while(rs.next()) { i++; %> <tr> <td id="att"><input type="text" id="sname" name="staff_name<%//=i%>" value="<%=rs.getString(1)%>"readonly ></td> <td><input type="radio" name="status<%=i%>" id="pre<%=i%>" value="present"></td> <td><input type="radio" name="status<%=i%>" id="abs<%=i%>" value="absent"></td> </tr> <%}%> </tbody> <%} catch(Exception e) { System.out.println("Sql exception in add jsp " + e.getMessage()); }finally {} %> </table></td> </tr> <tr> <td><input type="hidden" name="increment_no" value="<%=i%>"></td> <td><input type="submit" name="Submit" value="Submit" class="button" align="bottom" ></td> <td> </td> </tr> </table> </div> </form> <jsp:include page="footer.jsp"/> </body> </html>
Ads