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?
to get radio button value - Struts
how to get radio value
radio button value on edit action
Struts 2 radio button value problem
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
check radio button on retrieving the value from database.
how to check the radio button automatically depending up on the value of database when editing the form...
get a radio button click value - JSP-Servlet
Selecting a radio button in jquery autocomplete from database value
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)
get a value when a radio button clicked - JSP-Servlet
how to add fields at runtime in j2me
radio button
how to add components (like button , checkbox etc) in a table column in core java
Query on radio button
getting radio button at start of each row of table - Struts
get a value when a radio button clicked - JSP-Servlet
Dojo Radio Button
How to hide and show some field on a radio button click
How to use radio button in jsp page
how to check particular value is avilable in hashmap - Java Beginners
How to save form fields into the MySql Database without submit button in jsp?
radio button - Development process
Radio button Validation
Struts 2 Radio Button
how to insert value in dynamic table
how to display default radio button in struts2.0 for first time login - Struts
access into radio button
how to pass input from radio button to jsp page
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
validation of radio button
ModuleNotFoundError: No module named 'fieldy'
iPhone Radio Button Example
JSP Radio Button MySQL insert - JSP-Servlet
Using radio button in struts - Struts
com.vaadin - vaadin-radio-button-flow version 14.10.1 Maven dependency. How to use vaadin-radio-button-flow version 14.10.1 in pom.xml?
com.vaadin - vaadin-radio-button-flow version 22.2.0 Maven dependency. How to use vaadin-radio-button-flow version 22.2.0 in pom.xml?
How to add a column in a table
dependent radio button
radio button selection should move the control to a text box that needs to be complete
Radio Button in HTML
how to focus dojo slider to a particular value and then disabling dojo slider so that value not changes on clicking?

Ads