dcsimg
How to submit dynamic data into mysql and how i can show calender event for dynamic added row ::::::Below is the code..
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ramprakash
Posted On:   Wednesday, May 1, 2013 05:09 AM

in this code i can create the dynamic Row and when i click on the calender icon , the date is set to the pre texr box means not in the previous text image i also how i can sumit the selected data in MY sql. Please Please help me.. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*;" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD> <TITLE> Home3 </TITLE> &l   More>>






in this code i can create the dynamic Row and when i click on the calender icon , the date is set to the pre texr box means not in the previous text image

i also how i can sumit the selected data in MY sql.

Please Please help me..








<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE> Home3 </TITLE>
<SCRIPT language="javascript">
        
        function addRow(tableID) {
           
             var table = document.getElementById(tableID);
 
            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);
 
            var colCount = table.rows[0].cells.length;
 
            for(var i=0; i<colCount; i++) {
 
                var newcell = row.insertCell(i);
 
                newcell.innerHTML = table.rows[0].cells[i].innerHTML;
                //alert(newcell.childNodes);
                switch(newcell.childNodes[0].type) {
                    case "text":
                            newcell.childNodes[0].value = "";
                            break;
                    case "checkbox":
                            newcell.childNodes[0].checked = false;
                            break;
                    case "select-one":
                            newcell.childNodes[0].selectedIndex = 0;
                            break;
                }
            }
        }
 
        function deleteRow(tableID) {
            try {
            var table = document.getElementById(tableID);
            var rowCount = table.rows.length;
 
            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    if(rowCount <= 1) {
                        alert("Cannot delete all the rows.");
                        break;
                    }
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                }
 
 
            }
            }catch(e) {
                alert(e);
            }
        }
 
    </SCRIPT>

<script language="javascript" type="text/javascript" src="datetimepicker.js">
</script> 
 
</HEAD>
<BODY>
<%! String driverName = "com.mysql.jdbc.Driver";%>
<%!String url = "jdbc:mysql://localhost:3306/users";%>
<%!String user = "root";%>
<%!String psw = "root";%>

<form action="#">

<%
Connection con = null;
PreparedStatement ps = null;
try
{
Class.forName(driverName);
con = DriverManager.getConnection(url,user,psw);
String sql = "SELECT * FROM ProjectName";
ps = con.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
%>

 
     <input type="button" name="mysubmit" value="Add Row" onclick="addRow('dataTable')"></input>
 
    <INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" />
 
    <TABLE id="dataTable" width="350px" border="1">
        <TR>
            <TD>
           
              <SELECT name="country">
<%
while(rs.next())
{

String fname = rs.getString("Project Name");
%>
<option value="<%=fname %>"><%=fname %></option>
<%
}
%>
                </SELECT>
            </TD>
                
                   
              <TD><input id="demo1" type="text" size="25"><a href="javascript:NewCal('demo1','ddmmyyyy')"><img src="E:/Software/apache-tomcat-6.0.36/webapps/ROOT/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type ="text" name = "time" value = "" size="5"></TD>
        
          
             <TD><INPUT type="checkbox" name="chk"/></TD>
         
       <%
       Connection con1 = null;
       PreparedStatement ps1 = null;
       try
       {
       Class.forName(driverName);
       con1 = DriverManager.getConnection(url,user,psw);
       String sql1 = "SELECT* from ProjectName";
       ps1 = con.prepareStatement(sql1);
       ResultSet rs1 = ps.executeQuery();
       %>
       <td>
       <SELECT name="Activity">
       <%
      
       while(rs1.next())
       {
           String actname = rs1.getString("Activity");
       %>
       <option value="<%=actname %>"><%=actname %></option>
       <%
       }
       %>
       </SELECT>
       </td>
        </TR>
    </TABLE>
 <%
}
catch(SQLException sqe)
{
out.println(sqe);
}
%>
 <%
}
catch(SQLException sqe)
{
out.println(sqe);
}
%>
</BODY>
</HTML>

   <<Less
About | Sitemap | Contact