I am new in java and javascript. I want to pass a value from function in js file to JSP file. But I didn't get the value and it shows NULL. Let's say js file named as maintain.js and JSP file as form.jsp. Supposedly the value obtains from function check in maintain.js are pass to JSP file which when onclick it passes the value to the searchItem function which in the form.jsp
file.
In maintain.js
file
function check(){
var p = "apple";
var A = "form.jsp?apple=" + p;
}
In my form.jsp file
<div id="openModalDialog" align="center" style="display:none">
<form id="srch_grp">
<% String la=request.getParameter("apple");
System.out.println("apple:" + apple);
%>
<input type="button" name="btnitemsearch" value="Search" onclick="searchItem('<%=apple%>')">
</form>
</div>
In a console, I getapple:null
.
What do I wrong here?
Thank you in advance.