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

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









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
Get radio button value after submiting page
how to add fields at runtime in j2me
Drop down and radio button value on edit action
Retrieve value of radio button from database to form
how to check the radio button automatically depending up on the value of database when editing the form...
check radio button on retrieving the value from database.
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)
how to add components (like button , checkbox etc) in a table column in core java
get a radio button click value - JSP-Servlet
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 add a column in a table
How to add dynamic table in java
get a value when a radio button clicked - JSP-Servlet
How to add key value pair in Java
How to use radio button in jsp page
How to hide and show some field on a radio button click
how to check particular value is avilable in hashmap - Java Beginners
Dojo Radio Button
how to add two object in a particular file - Java Beginners
How to save form fields into the MySql Database without submit button in jsp?
How to add a columns with a button set to a Jtable built with database result set
how to insert value in dynamic table
how to dynamically add text boxes with add and remove link based on drop down choices, if a particular choice is selected.
how to display default radio button in struts2.0 for first time login - Struts
How to add value from sql server in dropdownlist
how to add a update button in the following jsp
radio button - Development process
how to pass input from radio button to jsp page
Radio button Validation
Struts 2 Radio Button
How do you add a numerical value to a regex
Radio Button Problem in jsp.
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page
access into radio button
ModuleNotFoundError: No module named 'fieldy'
validation of radio button
JSP Radio Button MySQL insert - JSP-Servlet

Ads