<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$(".date").datepicker({dateFormat:'dd/mm/yy'});
$('.chkValues').on('click', function() {
//get values of dates
var array = [];
var parent = $(this).closest('tr');
// Now find all the child <inpu> elements with class "date"
var last = 0;
$('.date', parent).each(function(i,e) {
var dt = new Date(e.value.split("/").reverse().join("-"));
alert(dt);
console.log(dt.getTime());
if (dt.getTime() <= last) {
alert('Error: ' + e.id + ' has an invalid value');
}
last = dt.getTime();
});
$row = $(this).data('row'); //row1, row2, row3 etc
$('input.' + $row).each(function() {
array.push($(this).val());
});
$('#btnSubmit').click(function(evt) {
evt.preventDefault();
$.ajax({
type: "POST",
url: "Test.jsp",
data: {array : array},
success: function(responseFromServer) {
$.each(responseFromServer, function(resultMessageKey,resultMessageValue) {
$('#content').html(resultMessageKey);
});
},
error: function() {
alert(" Ajax call Failed to Update Values into Database ");
}
});
});
});
});
</script>
</head>
<body>
<form action="" method="post">
<table id="tableData" width="100%" name="tableData">
<tr>
<th>Check/UnCheck</th>
<th>MYear</th>
<th>P Date</th>
<th>Q Date</th>
<th>B Date</th>
</tr>
<%
for (int i = 0; i < 5; i++) {
%>
<tr>
<td><INPUT type="checkbox" data-row="row<%=i%>" class="chkValues" id="ckbCheckAll" name="chkBox" type="checkbox" value="<%=i%>" size="50"></td>
<td align="left"><input class="inputText row1" type="text" name="mYear" id="mYear" value="2020"></td>
<td><input class="date row<%=i%>" id="pDate<%=i%>" name="dob" type="text" value="12/08/2020" /></td>
<td><input class="date row<%=i%>" id="qDate<%=i%>" name="dob" type="text" value="15/08/2020" /></td>
<td><input class="date row<%=i%>" id="bDate<%=i%>" name="dob" type="text" value="20/08/2020" /></td>
</tr>
<%
}
%>
</table>
<input id="btnSubmit" type="submit" name="submit" value="submit" />
</p>
</form>
</body>
</html>
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.