How to add radio button value in a table for particular field?

Ads
 

How to add radio button value in a table for particular field?

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>&nbsp;</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>&nbsp;</td>
                </tr>
               </table>
           </div>
        </form>
        <jsp:include page="footer.jsp"/>
    </body>
</html>
View Answers

Ads









Related Tutorials/Questions & Answers:
How to add radio button value in a table for particular field?
passing value of radio button
Advertisements
How to identify the radio button id and row id in a table in jsp?
how to get radio value
to get radio button value - Struts
radio button value on edit action
Struts 2 radio button value problem
how to add fields at runtime in j2me
how to check the radio button automatically depending up on the value of database when editing the form...
Get radio button value after submiting page
Drop down and radio button value on edit action
Retrieve value of radio button from database to form
struts2 how can we add an radio button to form using a class(doa)
struts2 how can we add an radio button to form using a class(doa)
check radio button on retrieving the value from database.
get a radio button click value - JSP-Servlet
how to add components (like button , checkbox etc) in a table column in core java
Selecting a radio button in jquery autocomplete from database value
get a value when a radio button clicked - JSP-Servlet
radio button
Query on radio button
getting radio button at start of each row of table - Struts
How to use radio button in jsp page
How to hide and show some field on a radio button click
How to save form fields into the MySql Database without submit button in jsp?
Dojo Radio Button
How to add dynamic table in java
get a value when a radio button clicked - JSP-Servlet
How to add a column in a table
how to display default radio button in struts2.0 for first time login - Struts
how to pass input from radio button to jsp page

Ads