I am currently developing a JSP web page which includes an input text field where users can choose a date. I need to retrieve this selected date value and update it in my database by invoking a Java method that I have created.
The HTML for the input field is as follows:
End Date:<input class="txtEndDate" type="text" id="txtEndDate" name="txtEndDate" readonly/><br><br>
Below is the snippet of my Javascript function:
// function to save data into table
function save() {
var enddate = $('#txtEndDate').val();
<%
// function to update the value
fileFacade.insert_update(id, uniquecode, date, enddate);
%>
}
Although JavaScript runs on the client side and Java on the back end, I still need to pass the enddate
as a function parameter. Is there any way I could achieve this?
EDIT:
updateURL.jsp:
<%@ page import="java.sql.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Locale" %>
<%@include file="../../../WEB-INF/jspf/mcre.jspf" %>
<%@include file="../../../WEB-INF/jspf/session.jspf"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
</head>
<body>
<%
long fileID = Long.parseLong(request.getParameter("id"));
String uniquecode=request.getParameter("uniquecode");
String startdt=request.getParameter("startdate");
String enddate=request.getParameter("enddate");
int enablestatus= Integer.parseInt(request.getParameter("enable"));
fileFacade.insert_update(fileID, uniquecode, startdt, enddate, enablestatus);
%>
</body>
</html>