<table>
<tr>
<td> </td>
<td>
<a id=<%= id%> href="javascript:redirect()" >
<img src=<%= s%> style="width:90px; height:90px;" />
</a>
</td>
<td>
<p>Product Name : <%= name %></p>
<p>Product Price : <%= list.get(i).getProdPrice() %></p>
</td>
</tr>
</table>
I need to get the value of <%= id%> in jsp code [<a id=<%= id%> href="javascript:redirect()" >] in my javascript. I am calling a javascript redirect(),
How can I get the value of id in my javascript? This is my javascript.
function redirect(){
var a = document.getElementById("id").value;
alert(a);
}
I need to get the value in javascript function and need to submit the page from javascript.
I am using struts2 framework.
If I understand the question correctly, you need to pass the value <%= id%> to your javascript function. you can do this by making the following changes to your code
change the javascript function to :
and attach redirect in the JSP
as