I am trying to pass value from one JSP page to another page using jquery.In below code I would like to pass the variable “processId” to another page. The value should pass to another page after the below JSP page is loaded.
I am getting error: “procId is undefined”
<head>
<script type="text/javascript" src="jqwidgets/scripts/jquery-1.8.1.min.js"></script>
<script type="text/javascript">
window.onload=passValue;
function passValue()
{
$.post("Testing.jsp", {processId: ""+procId+""});
}
</script>
</head>
<%
String processId = "555";
%>
<form name="fm" id="fm">
<input type="hidden" id="procId" value="<%=processId%>" name="processId">
</form>
</html>
jQuery calls should be placed within the standard block:
With this block, the code won’t execute until the DOM is fully loaded; you don’t need to assign a function to window.onload.
Next, to grab the value of the input with id “procId”, you need to create a jQuery object using the regular syntax:
$('#procId'), then access its value with.val()So this should do it: